CSVParse for Node.js


Option ltrim

The ltrim option ignore whitespace characters from the left side of a CSV field. Defaults to false. It does not remove whitespace present inside the quotes of a field.

Refer to the trim documentation to learn about which characters are interpreted as whitespaces.


This example declare spaces around fields at multiple locations. The ones on the left side are trimmed while the other ones are preserved.

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

const data = [
  'a ,1',
  'b, 2 ',
  ' c,3'
const records = parse(data, {
  ltrim: true
  records, [
    [ 'a ', '1' ],
    [ 'b', '2 ' ],
    [ 'c', '3' ]


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