{"id":16563,"library":"udsv","title":"μDSV - A Fast CSV Parser","description":"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.","status":"active","version":"0.7.3","language":"javascript","source_language":"en","source_url":"https://github.com/leeoniya/uDSV","tags":["javascript","csv","parse","parser","typescript"],"install":[{"cmd":"npm install udsv","lang":"bash","label":"npm"},{"cmd":"yarn add udsv","lang":"bash","label":"yarn"},{"cmd":"pnpm add udsv","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Used to automatically detect the CSV structure from a string sample. The library is ESM-first.","wrong":"const { inferSchema } = require('udsv');","symbol":"inferSchema","correct":"import { inferSchema } from 'udsv';"},{"note":"Initializes a parser instance with a given schema, which can be inferred or custom.","wrong":"const { initParser } = require('udsv');","symbol":"initParser","correct":"import { initParser } from 'udsv';"},{"note":"These are methods of the parser instance, used to obtain raw string arrays or schema-typed objects after parsing.","symbol":"parser.stringArrs / parser.typedObjs","correct":"const parser = initParser(schema);\nconst stringArrays = parser.stringArrs(csvStr);\nconst typedObjects = parser.typedObjs(stringArrays);"}],"quickstart":{"code":"import { inferSchema, initParser } from 'udsv';\n\nconst csvString = 'name,age,city\\nAlice,30,New York\\nBob,24,London\\nCharlie,35,\"Paris, France\"';\n\n// 1. Infer schema from the CSV string\nconst schema = inferSchema(csvString);\nconsole.log('Inferred Schema:', schema);\n\n// 2. Initialize the parser with the schema\nconst parser = initParser(schema);\n\n// 3. Parse to arrays of strings (raw values)\nconst stringArrays = parser.stringArrs(csvString);\nconsole.log('Parsed as String Arrays:', stringArrays);\n/* Output: [\n  ['name', 'age', 'city'],\n  ['Alice', '30', 'New York'],\n  ['Bob', '24', 'London'],\n  ['Charlie', '35', 'Paris, France']\n] */\n\n// 4. Parse to typed objects (using the inferred schema's types)\nconst typedObjects = parser.typedObjs(stringArrays);\nconsole.log('Parsed as Typed Objects:', typedObjects);\n/* Output: [\n  { name: 'Alice', age: 30, city: 'New York' },\n  { name: 'Bob', age: 24, city: 'London' },\n  { name: 'Charlie', age: 35, city: 'Paris, France' }\n] */\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"Line 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`.","severity":"gotcha","affected_versions":">=0.5.0"},{"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.","message":"uDSV'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.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"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'\"."},{"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.","cause":"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.","error":"CSV parsing error: Unexpected character after quoted field (e.g., '\"value\"extra' instead of '\"value\",next')."}],"ecosystem":"npm"}