μDSV - A Fast CSV Parser

0.7.3 · active · verified Wed Apr 22

uDSV (μDSV) is a lightweight and exceptionally fast JavaScript library for parsing CSV strings, adhering mostly to RFC 4180. Currently at version 0.7.3, it maintains an active release cadence with frequent minor updates. A key differentiator is its "Ludicrous Speed™" performance, consistently outperforming popular alternatives like Papa Parse by 2x-5x across various datasets and parsing configurations, ensuring high speed not just on simplified "happy paths." The library is designed for the 99.5% use-case, minimizing complexity and performance trade-offs, making it ideal for robust, high-throughput parsing. It offers both full and incremental parsing, automatic delimiter detection, schema inference with value typing (`string`, `number`, `boolean`, `date`, `json`), and flexible output formats including arrays, objects, and columnar arrays, all within a compact 5KB (minified) footprint and ships with TypeScript types.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to infer a schema from a CSV string, initialize the parser, and then parse the data into both raw string arrays and schema-typed objects for easier manipulation.

import { inferSchema, initParser } from 'udsv';

const csvString = 'name,age,city\nAlice,30,New York\nBob,24,London\nCharlie,35,"Paris, France"';

// 1. Infer schema from the CSV string
const schema = inferSchema(csvString);
console.log('Inferred Schema:', schema);

// 2. Initialize the parser with the schema
const parser = initParser(schema);

// 3. Parse to arrays of strings (raw values)
const stringArrays = parser.stringArrs(csvString);
console.log('Parsed as String Arrays:', stringArrays);
/* Output: [
  ['name', 'age', 'city'],
  ['Alice', '30', 'New York'],
  ['Bob', '24', 'London'],
  ['Charlie', '35', 'Paris, France']
] */

// 4. Parse to typed objects (using the inferred schema's types)
const typedObjects = parser.typedObjs(stringArrays);
console.log('Parsed as Typed Objects:', typedObjects);
/* Output: [
  { name: 'Alice', age: 30, city: 'New York' },
  { name: 'Bob', age: 24, city: 'London' },
  { name: 'Charlie', age: 35, city: 'Paris, France' }
] */

view raw JSON →