CSV for Node.js

IssuesGitHub

Comprehensive CSV suite combining 4 well tested packages to generate, parse, transform and stringify CSV data.

csv-generate

CSV Generate build status NPM version

Write random and user-defined strings, objects and arrays

csv-parse

CSV parse build status NPM version

Read CSV strings and buffers and write object and arrays

stream-transform

Stream transform build status NPM version

Read and write objects and arrays

csv-stringify

CSV stringify build status NPM version

Read object and arrays and write CSV strings

CSV & JSON convertor tool

This is a full-featured CSV parsing tool running entirely on your browser. No data leave your computer ! Use it also to learn how to use our packages and to test the various options interactively.

Convertor tool

Latest news

New `comment_no_infix` option.

By wdavidw | August 25th, 2023

Version 5.5.0 of csv-parse include the new [`comment_no_infix` option](/parse/options/comment_no_infix/). When activate, comments may only start at the begining of a line.

Try the new CSV & JSON conversion tool!

By wdavidw | January 15th, 2019

We just published a new conversion tool which takes a CSV input and convert it to JSON. Use it as a playground to learn how to use our packages, test your options interactively or as a full-featured CSV parsing tool.

CSV 5.0.0

By wdavidw | November 21th, 2018

Version 5.0.0 includes the latest csv-parse and csv-stringify respectively with version 4.0.1 and 5.0.0.

CSV Stringify 5.0.0

By wdavidw | November 21th, 2018

Version 5.0.0 introduces the new quoted_match option and support options written both in the underscore and camelcase forms. Some options were renamed. Thus rowDelimiter is now record_delimiter and formatters is now cast. Read the changelog!

CSV Parse 4.0.0 - re-writing and performance

By wdavidw | November 19th, 2018

Version 4.0.0 is a complete re-writing of the project focusing on performance. It also comes with new functionalities as well as some cleanup in the option properties and the exported information. The official website is updated and the changelog contains the list of changes for this major release. Learn more!

Quick sync example

import assert from "node:assert";
import { generate, parse, transform, stringify } from "csv/sync";

// Run the pipeline
const input = generate({ seed: 1, columns: 2, length: 2 });
const rawRecords = parse(input);
const refinedRecords = transform(rawRecords, (data) =>
  data.map((value) => value.toUpperCase())
);
const output = stringify(refinedRecords);
// Print the final result
assert.equal(output, `OMH,ONKCHHJMJADOA
D,GEACHIN
`);

Quick stream pipe example

// Import the package
import * as csv from 'csv';

// Run the pipeline
csv
  // Generate 20 records
  .generate({
    delimiter: '|',
    length: 20
  })
  // Transform CSV data into records
  .pipe(csv.parse({
    delimiter: '|'
  }))
  // Transform each value into uppercase
  .pipe(csv.transform((record) =>
    record.map((value) =>
      value.toUpperCase()
    )
  ))
  // Convert objects into a stream
  .pipe(csv.stringify({
    quoted: true
  }))
  // Print the CSV stream to stdout
  .pipe(process.stdout);

About

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