CSVStringify for Node.js


Sync API

The sync API behave like a pure function. For a given input made of the input data set and its options, it always produce the same output data.

This represent a regular direct synchronous call to a function: you pass records and it return a CSV text. Because of its simplicity, this is the recommended approach if you don't need scalability and if your dataset fit in memory.

The module to import is csv-stringify/sync and the signature is const data = stringify(records, [options]) as shown in the sync example:

import { stringify } from 'csv-stringify/sync';
import assert from 'assert';

const output = stringify([
  [ '1', '2', '3', '4' ],
  [ 'a', 'b', 'c', 'd' ]

assert.equal(output, '1,2,3,4\na,b,c,d\n');


The Node.js CSV project is an open source product hosted on GitHub and developed by Adaltas.