CSVParse for Node.js


Option rtrim

The rtrim option ignore whitespace characters from the right 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 right 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, {
  rtrim: 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.