API Reference
csv-stringify
CSV stringifier with column control, headers, quoting, and streaming for Node.js.
Official Documentation ↗CompatibilityThis documentation covers version
v6. Check the official docs for the latest API surface.Installation
npm
npm install csv-stringifyMethods
No methods match this filter.
csv-stringify converts arrays or objects into CSV text, either buffered or as a stream.
Key Features
- Header row generation from object keys
- Quoting and delimiter configuration
- Stream transform for large outputs
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Security
Official security statements captured from the package documentation:
- escape_formulas 选项用于防御 CSV 注入 — “-
escape_formulas(boolean) Since version 6.3.0 Escape values that start with=,+,-,@,\t, or\rwith'and defend against CSV injection attacks.” (source: https://csv.js.org/stringify/options/, fetched 2026-11-08T17:48:10.000Z)
API reference evidence
Fetched from official sources on 2026-11-08T17:48:10.000Z via WebFetch https://csv.js.org/stringify/api/sync/.
stringify→ signature from https://csv.js.org/stringify/api/sync/; official text: “The module to import iscsv-stringify/syncand the signature isconst data = stringify(records, [options])”columns option→ signature from https://csv.js.org/stringify/options/; official text: “-columns(array|object) Since version 0.0.1 Influence the generation of records at the field level.”
FAQ
- Which option enables headers?
- Set header: true to emit a header row; the labels come from object keys or the columns option headers.
- How do I protect against CSV injection?
- Prefix cells beginning with =, +, -, or @ when they are user-controlled, since spreadsheets may interpret them as formulas.
- Can I stream a huge result set?
- Yes. Use the Stringifier transform and pipe records into it so only a small buffer is held at a time.
Report a problem with this API docOpens a pre-filled issue on GitHub.