CSVStringify for Node.js

IssuesGitHub

Option quoted_string

Quote all fields of type string. This option apply even when there is no character requiring quotes.

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

Example

The quoted_string example illustrates that only fields of type string, empty or not, are quoted.

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.