CSVStringify for Node.js

IssuesGitHub

Option quoted_empty

Quote empty strings. It overrides quoted_string on empty strings when defined.

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

Example

In the quoted_empty example, every field evaluated as empty is 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.