CSVStringify for Node.js

IssuesGitHub

Option record_delimiter

The record_delimiter option define the characters used to separate each record from one another.

You can pass any value of at least one character in the form of a string or a Buffer. Special values include:

  • unix: equivalent of \n
  • mac: equivalent of \r
  • windows: equivalent of \r\n
  • ascii: equivalent of \u001e
  • unicode: equivalent of \u2028

History

This option was named rowDelimiter until version 4.3.1.

Example

The default value is the newline ASCII character \n. The example defines the custom pipe character instead:

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

const records = stringify([
  ['a', 'b'],
  ['c', 'd']
], {
  record_delimiter: '|',
  eof: false,
});

assert.equal(records, 'a,b|c,d');

About

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