OptionalallowAllow experimental or non-standard compression formats not explicitly supported by this library.
When true, compression formats from Content-Encoding headers that are not in the
default supported list will be passed to the runtime's DecompressionStream without
validation. This allows using compression formats that may not be universally supported
across all browsers.
When false (default), only universally supported formats are allowed:
gzip, deflate, br (Brotli)gzip, deflateSome compression formats are only supported in specific environments:
deflate-raw: Supported in Chromium-based browsers (Chrome, Edge) but may not work
in Firefox or Safaribr (Brotli): Future browser support may varyIf you enable this option and use deflate-raw:
Use with caution: Enabling this bypasses library validation and relies entirely on runtime error handling. If the runtime doesn't support the format, you'll get a runtime error instead of a clear validation error from this library.
// Safe mode (default): Only universally supported formats
const response = await fetch('data.csv.gz');
await parse(response); // ✓ Works in all browsers
// Experimental mode: Allow deflate-raw (Chromium-only)
const response = await fetch('data.csv'); // Content-Encoding: deflate-raw
await parse(response, { allowExperimentalCompressions: true });
// ✓ Works in Chrome/Edge
// ✗ May fail in Firefox/Safari
// Browser-aware usage
const isChromium = navigator.userAgent.includes('Chrome');
await parse(response, {
allowExperimentalCompressions: isChromium
});
OptionalcharsetYou can specify the character encoding of the binary.
TextDecoderStream is used internally.
See Encoding API Compatibility for the encoding formats that can be specified.
OptionaldecompressionIf the binary is compressed by a compression algorithm, the decompressed CSV can be parsed by specifying the algorithm.
OptionaldelimiterCSV field delimiter.
If you want to parse TSV, specify '\t'.
OptionalengineEngine configuration for CSV parsing.
OptionalfatalIf the binary has a invalid character, you can specify whether to throw an error.
If the property is true then a decoder will throw a TypeError
if it encounters malformed data while decoding.
If false the decoder will substitute the invalid data
with the replacement character U+FFFD (�).
See TextDecoderOptions.fatal for more information.
OptionalheaderCSV header.
OptionalignoreIf the binary has a BOM, you can specify whether to ignore it.
If you specify true, the BOM will be ignored. If you specify false or not specify it, the BOM will be treated as a normal character. See TextDecoderOptions.ignoreBOM for more information about the BOM.
OptionalmaxMaximum binary size in bytes for ArrayBuffer/Uint8Array inputs.
OptionalmaxMaximum internal buffer size in characters.
This option limits the size of the internal buffer used during lexing
to prevent memory exhaustion attacks. The buffer size is measured in
UTF-16 code units (JavaScript string length). When the buffer exceeds
this limit, a RangeError will be thrown.
Set to Infinity to disable the limit (not recommended for untrusted input).
OptionalmaxMaximum number of fields allowed per record.
OptionalquotationCSV field quotation.
OptionalsignalThe signal to abort the operation.
const controller = new AbortController();
const csv = "foo,bar\n1,2\n3,4";
try {
const result = await parse(csv, { signal: controller.signal });
} catch (e) {
if (e instanceof DOMException && e.name === "AbortError") {
console.log("Aborted");
}
}
// Abort with user action
document.getElementById("cancel-button")
.addEventListener("click", () => {
controller.abort();
});
OptionalskipWhen true, completely empty lines (with only delimiters or whitespace) will be skipped during parsing.
Parse options for CSV binary.