fast-csv
Streaming CSV parser and formatter for Node.js with zero runtime dependencies and full TypeScript support.
Repository Health
Technical Analysis
fast-csv is a Node.js library for parsing and formatting CSV (or any delimited) data as streams. It ships as three packages published from one monorepo: @fast-csv/parse and @fast-csv/format handle each direction independently with zero runtime dependencies, while the umbrella fast-csv package re-exports both for projects that need to read and write CSV in the same codebase.
Because every operation is built on Node’s Transform/Writable streams, fast-csv can parse or generate CSV files far larger than available memory, piping rows in as they’re read and out as they’re produced. Configurable headers, delimiters, quoting, and row-level transform/validation hooks cover the edge cases that come up in real-world CSV data, and the library has stayed in production use handling large-scale data import/export workloads since 2012.
What You Get
- A streaming CSV parser (parse, parseFile, parseStream, parseString) that emits rows as they’re read instead of buffering the whole file
- A streaming CSV formatter (format, write, writeToStream, writeToBuffer, writeToString, writeToPath) covering every common output target
- Zero runtime dependencies in the core @fast-csv/parse and @fast-csv/format packages
- Full TypeScript typings generated from the TypeScript source, with generics for input/output row shapes
- Configurable headers, delimiters, quote/escape characters, and per-row transform/validation hooks
Common Use Cases
- Importing large CSV uploads into a database without high memory usage
- Exporting query results as downloadable CSV reports from a web backend
- Building CSV-to-JSON or JSON-to-CSV conversion CLIs
- Normalizing and validating rows inside Node-based ETL pipelines
Under The Hood
Architecture The repo is a pnpm + Lerna monorepo split into three published packages under packages/: @fast-csv/parse, @fast-csv/format, and fast-csv (packages/fast-csv/src/index.ts), which is a thin barrel re-exporting both. Parsing is driven by CsvParserStream (packages/parse/src/CsvParserStream.ts), a Node Transform stream that feeds raw chunks to a Parser (parser/Parser.ts) built on a hand-rolled Scanner/Token tokenizer (parser/Scanner.ts, parser/Token.ts) and dedicated QuotedColumnParser/NonQuotedColumnParser classes; parsed rows then flow through a HeaderTransformer and RowTransformerValidator (transforms/) before CsvParserStream pushes them downstream, with explicit bookkeeping for row counts, header emission, and skip/limit options. Formatting mirrors this shape in reverse: CsvFormatterStream delegates to RowFormatter/FieldFormatter for row and field-level serialization. The two directions share only type contracts (Row, RowMap, RowArray), composed solely by the umbrella package.
Tech Stack Written in TypeScript (5.9, compiled via tsc against tsconfig.build.json) targeting Node >=20. @fast-csv/parse and @fast-csv/format carry no runtime dependencies at all; only the umbrella fast-csv package depends on the two split packages at a pinned version. The workspace is orchestrated with pnpm workspaces and Lerna 9 for versioning/publishing, tested with Jest 30 + ts-jest (—runInBand —coverage), linted with ESLint 9 (typescript-eslint, —max-warnings 0) and formatted with Prettier, with commitlint (Angular config) and Husky enforcing commit and pre-commit hygiene. A separate Docusaurus site lives under documentation/, and dedicated example packages (examples/parsing-js, examples/fast-csv-ts, etc.) plus a benchmark package round out the workspace. CI runs via GitHub Actions (test.yml, dependency-review.yml).
Code Quality Both packages carry extensive Jest suites — ParserOptions, CsvParsingStream, and per-component specs (parser/Scanner, parser/Parser, parser/RowParser, transforms/HeaderTransformer, transforms/RowTransformerValidator) on the parse side, and FormatterOptions/CsvFormatterStream/RowFormatter/FieldFormatter specs on the format side — plus dedicated regression tests filed per GitHub issue in an issues/ folder in each package, a strong sign that fixes get locked in with tests rather than just patched. Error handling is explicit and callback-based throughout, with CsvParserStream guarding against a done callback being invoked twice after an error and distinguishing a ‘data-invalid’ event from a hard stream error. Naming is consistent and single-purpose (Scanner/Token/Parser/RowParser; RowFormatter/FieldFormatter), typing is strict with row-shape generics, and ESLint/Prettier/Husky/CI enforce style and correctness before merge.
What Makes It Unique The standout technical choice is that @fast-csv/parse and @fast-csv/format ship with zero runtime dependencies: rather than wrapping an existing CSV grammar library, the project implements its own character-level Scanner/tokenizer to handle quoting, escaping, and custom delimiters, giving it a materially smaller supply-chain surface than dependency-heavier alternatives. That’s paired with a fully streaming, backpressure-aware Transform-stream API on both the read and write side, and a deliberate split into independently installable sub-packages so consumers who only need one direction don’t pull in the other. The core value proposition — streaming CSV I/O — is a well-trodden problem, so the innovation is in the disciplined, dependency-free implementation rather than a new idea.
Used by 2 apps in this directory
Laudspeaker
Marketing · Automation
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.
ToolJet
Low Code Platforms · No Code Platforms · AI Agents
Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.