csv-stringify is a JavaScript library designed to convert data records into CSV (Comma Separated Values) formatted text. It primarily implements the Node.js `stream.Transform` API, allowing for efficient processing of large datasets by handling data in chunks rather than loading entire files into memory. The package also provides convenient synchronous and callback-based APIs for simpler use cases. First released in 2010, it boasts a mature codebase, comprehensive test coverage, and a focus on scalability and customizability, supporting various delimiters, quotes, escape characters, and headers. It is currently at version 6.7.0 (as of early 2026), indicating active maintenance and consistent updates. It is often used as part of the broader `node-csv` ecosystem alongside `csv-parse`, `csv-generate`, and `stream-transform` to build complete CSV processing pipelines.
npm install csv-stringifyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the synchronous API for `csv-stringify` to convert an array of arrays into a CSV string, including custom delimiters and headers.
Update import statements to use `import { stringify } from 'csv-stringify/sync';` for ESM or `const { stringify } = require('csv-stringify/sync');` for CommonJS.Ensure your project is configured for ESM if you intend to use `import` statements, and be mindful of module resolution in older Node.js environments. If experiencing issues, verify Node.js version compatibility (Node 12+ for `exports` field) or consider `require('csv-stringify/dist/cjs/sync.cjs')` for older CJS setups.Always ensure the writable stream is explicitly ended after all data has been written, for example, by calling `stream.end()` or ensuring the upstream readable stream finishes and pipes correctly.
Set `header: true` in the options for CSV output to include a header row. If using object input, specify the `columns` option as an array of strings (for the order) or objects (for mapping/formatting).
For synchronous stringification, use `import { stringify } from 'csv-stringify/sync';` or `const { stringify } = require('csv-stringify/sync');`. If using the main module, remember it provides the stream/callback API.Ensure that data is only written to the stream while it is still open. Check upstream data sources for premature closure or ensure `stream.end()` is not called too early.
No dependency data recorded yet.