CSVStringify for Node.js

IssuesGitHub

Option quoted

Quote all the non-empty fields even when there is no character requiring quotes.

By default, only the fields containing a special character such a delimiter or a quote are surrounded by quotes.

Note, several options are available to control when to quote fields under certain conditions. Make sure to review the alternatives.

Example using "quote"

In the quoted example, every field evaluated as empty is not quoted. It includes an empty string and values of false, null and undefined.

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

const records = stringify([
  ['1', ''],
  [false, '2'],
  ['3', null],
  [undefined, '4']
], {
  quoted: true
});

assert.equal(records, '"1",\n,"2"\n"3",\n,"4"\n');

About

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