Registry / serialization / udsv
library0.7.3jsnpmunverified

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.

npm install udsv
INSTALL
IMPORT
SIG · UDSV
U
udsv
serializationjavascriptv0.7.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

inferSchema
import { inferSchema } from 'udsv';
const { inferSchema } = require('udsv');
Used to automatically detect the CSV structure from a string sample. The library is ESM-first.
initParser
import { initParser } from 'udsv';
const { initParser } = require('udsv');
Initializes a parser instance with a given schema, which can be inferred or custom.
parser.stringArrs / parser.typedObjs
const parser = initParser(schema); const stringArrays = parser.stringArrs(csvStr); const typedObjects = parser.typedObjs(stringArrays);
These are methods of the parser instance, used to obtain raw string arrays or schema-typed objects after parsing.

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' } ] */
Debug
Known issues
gotchaLine breaks within quoted CSV values must exactly match the row separator used throughout the rest of the CSV. For example, if rows are separated by `\n`, quoted fields containing line breaks must also use `\n`, not `\r\n` or `\r`.
fix
Ensure consistent line ending usage across the entire CSV file, particularly within quoted fields, to match the chosen row delimiter. Most tools can standardize line endings.
affects: >=0.5.0
gotchauDSV's advanced `typed*()` methods (e.g., `typedObjs`, `typedArrs`) rely on dynamically-generated functions via `new Function()`. Environments with strict Content Security Policy (CSP) headers that disallow `unsafe-eval` will prevent these methods from functioning.
fix
If `unsafe-eval` cannot be enabled in your CSP, you must manually perform type conversions on the raw string outputs provided by `parser.stringArrs()` or similar methods.
affects: >=0.5.0
Errors
Common errors & fixes
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source in the following Content Security Policy directive: "script-src 'self'".
Your browser environment has a strict Content Security Policy that prohibits the use of `eval` or `new Function()`, which uDSV's typed parsing methods depend on.
fix
Either adjust your CSP to allow `unsafe-eval` (if your security policy permits), or switch to using `parser.stringArrs()` to get raw string outputs and implement manual type conversion logic in your application.
CSV parsing error: Unexpected character after quoted field (e.g., '"value"extra' instead of '"value",next').
This often occurs when a character immediately follows a closing quote without a delimiter, violating RFC 4180 rules. Or, line breaks within a quoted field do not match the row delimiter.
fix
Verify that your CSV strictly adheres to RFC 4180. Ensure no extraneous characters exist after quoted fields before a delimiter or newline. Also, confirm that all line breaks inside quoted fields are identical to the file's primary row delimiter.
Upgrade
Version history
0.7.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
udsv — npm install udsv · libregistry