CSVParse for Node.js


Option comment

Treat all the characters after this one as a comment. It can be made of one or multiple escape characters. It is disabled by default by defining an empty string "".

  • Type: boolean
  • Optional
  • Default: ""
  • Since: early days

The escape sequence can be defined at the begining of record (a line if the record delimiter is a line return) or anywhere else. Every characters found after the escape sequence will be disregarded.

Escaping is disabled inside a quoted field. The escape sequence will be preserved like any other bytes. It cannot be escaped.


The comment example insert two comments, one at the begining of the file and another one after a record.

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

const data = `
# At the beginning of a record
"world"# At the end of a record
const records = parse(data, {
  comment: "#"
assert.deepStrictEqual(records, [
  [ 'hello' ],
  [ 'world' ]


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