npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

csv-easy

v0.1.0

Published

A lightweight, zero-dependency CSV parser for Node.js

Readme

csv-easy

A zero-dependency CSV parser for Node.js 18 and newer. It supports strings, streams, and Express middleware.

Install

npm install csv-easy

Quick start

import { parseCSV } from "csv-easy";

const rows = parseCSV("name,age\nAda,18");
console.log(rows);
// [{ name: "Ada", age: "18" }]

By default, the first row is used for headers and values are strings.

Options

| Option | Default | Description | |---|---|---| | delimiter | "," | Single character between fields. | | quote | "\"" | Single character for quoted fields. Must differ from delimiter. | | trim | false | Trims unquoted fields and header names. | | headers | true | true uses the first row, false returns arrays, or pass custom header names. | | skipEmptyLines | true | Skips blank rows. | | maxRows | Infinity | Maximum number of data rows. Exceeding it throws CsvParseError. | | cast | false | Enables built-in value casting, per-rule flags, or a custom function. | | maxBytes | 1_000_000 | Middleware only: maximum raw request body size in bytes. | | property | "csv" | Middleware only: request property to receive parsed rows. | | timeout | 30_000 | Middleware only: request read timeout in milliseconds. |

delimiter and quote must each be one character. Delimiter cannot be a quote or newline; quote cannot be a newline.

Casting

cast: true converts strict decimal numbers, lowercase true and false, and empty unquoted values to null. Dates are not cast unless date: true is set. Quoted fields are not auto-cast. You can enable or disable individual rules with an object:

parseCSV("name,age\nAda,18", { cast: { number: true } });

A custom cast function receives (value, context). The context has column, index, row, and quoted properties.

Streaming

createParseStream returns a Node.js transform stream that emits one parsed row at a time:

import fs from "node:fs";
import { createParseStream } from "csv-easy";

fs.createReadStream("data.csv")
  .pipe(createParseStream({ cast: true }))
  .on("data", (row) => console.log(row));

Middleware

Use csvMiddleware after any middleware that should run first. It reads raw requests with Content-Type: text/csv (including a charset parameter) and sets req.csv by default. Parsing failures are passed to next(err); the middleware does not send a response.

import express from "express";
import { csvMiddleware } from "csv-easy";

const app = express();
app.post("/upload", csvMiddleware({ cast: true }), (req, res) => {
  res.json(req.csv);
});

Express and multer are optional peer usage examples; neither is installed by this package. With multer already configured, the middleware parses its in-memory buffer or disk path:

import multer from "multer";

const upload = multer({ storage: multer.memoryStorage() });
app.post("/upload", upload.single("file"), csvMiddleware(), (req, res) => {
  res.json(req.csv);
});

For multiple files, use multer's upload.array(...) or upload.fields(...). One file produces an array of rows. Multiple files produce an object keyed by field name, with each value an array of results.

Errors

CsvParseError has message, row (1-based), and status (400). Middleware size errors have status 413 and timeouts have status 408. Option and input type errors are TypeError instances.

import { CsvParseError, parseCSV } from "csv-easy";

try {
  parseCSV('name\n"unfinished');
} catch (err) {
  if (err instanceof CsvParseError) {
    console.log(err.message, err.row, err.status);
  }
}

Limitations

The package does not parse multipart requests itself; use multer or another upload middleware first. It parses CSV but does not write CSV files.