████████╗██╗ ██╗██████╗ ██████╗ ██████╗ ██████╗███████╗██╗ ██╗ ╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██╔═══██╗██╔════╝██╔════╝██║ ██║ ██║ ██║ ██║██████╔╝██████╔╝██║ ██║██║ ███████╗██║ ██║ ██║ ██║ ██║██╔══██╗██╔══██╗██║ ██║██║ ╚════██║╚██╗ ██╔╝ ██║ ╚██████╔╝██║ ██║██████╔╝╚██████╔╝╚██████╗███████║ ╚████╔╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝╚══════╝ ╚═══╝
High-performance CSV parser with SIMD acceleration
Built with Zig for native performance. Fast Mode now leads the benchmark suite for clean CSV data.
bun add turbocsvEnd-to-end benchmark including file reads on Apple Silicon. Clean generated CSV data. Higher is better.
| Library | 1K rows | 10K rows | 100K rows |
|---|---|---|---|
| TurboCSV Fast Mode | 116.5 MB/s | 177.4 MB/s | 172.4 MB/s |
| PapaParse | 65.8 MB/s | 98.7 MB/s | 111.5 MB/s |
| TurboCSV Native | 42.5 MB/s | 53.0 MB/s | 57.6 MB/s |
| csv-parse | 25.1 MB/s | 35.1 MB/s | 33.3 MB/s |
| fast-csv | 22.7 MB/s | 33.5 MB/s | 32.6 MB/s |
Fast Mode is optimized for simple CSV without quoted delimiters or multi-line fields. Run it yourself: bun run benchmark:compare
ARM64 NEON and x86 SSE2 vector instructions for parallel character scanning at native speed.
CSV injection protection, structured error reporting, skip bad rows, size limits, column relaxation.
Pandas-like operations: select, filter, sort, groupBy, join with lazy evaluation.
TypeScript-only parser for clean data. Dynamic typing, cast functions, nested JSON support.
All parser options accessible via CLI: trim, comments, range processing, error handling, and more.
Process files larger than RAM. Zero-copy parsing keeps data out of the JS heap.
Full support for quoted fields, escaped quotes, and multi-line values.
Native binaries for macOS, Linux, Windows. WASM fallback for universal compatibility.
Current toolchain support, clearer benchmarks, and Fast Mode performance visibility.
bun run benchmark restored with generated sample filesbenchmark:compare now reports native and Fast Mode separatelystd.Io file APIs replace deprecated filesystem callsDebugAllocator replaces the old general-purpose allocatorArrayList usage updated for allocator-explicit methodsMajor feature release — 22 CLI flags, security hardening, Fast Mode, and robust error handling.
escapeFormulaeskipRecordsWithError — silently drop malformed rowsmaxRecordSize — reject oversized rowstrim, ltrim, rtrim — strip whitespaceskipEmptyRowsfromLine / toLine — parse file rangescomments: trueflatten() / unflatten() for nested JSONunparse() with flattenObjects optionbeforeFirstChunk — transform raw dataonRecord — per-record filtering/transformimport { CSVParser } from "turbocsv";
const parser = new CSVParser("data.csv");
for (const row of parser) {
console.log(row.get("name"), row.get("email"));
}
parser.close();import { CSVParser, unparse, flatten } from "turbocsv";
// Robust parsing with error handling
const parser = new CSVParser("messy.csv", {
trim: true, // Clean whitespace
skipRecordsWithError: true, // Skip bad rows
comments: true, // Skip # prefixed lines
duplicateHeaders: "rename", // Handle duplicate columns
dynamicTyping: true, // Auto-convert types
maxRecordSize: 10000, // Reject huge rows
cast: { // Custom transformers
price: (val) => parseFloat(val.replace("$", "")),
date: (val) => new Date(val)
}
});
// Process with structured error handling
for (const row of parser) {
try {
processRow(row);
} catch (error) {
if (error.code === "TooFewFields") {
console.log(`Row ${error.row}: Missing fields`);
}
}
}
// Secure CSV output
const csv = unparse(data, {
escapeFormulae: true, // Prevent CSV injection
flattenObjects: true // Handle nested JSON
});import { CSVParser } from "turbocsv";
const parser = new CSVParser("data.csv");
const df = parser.toDataFrame();
// Chain operations
const result = df
.filter(row => row.age > 18)
.select("name", "email", "age")
.sorted("name", "asc")
.first(100);
// Aggregation
const grouped = df.groupBy("department", [
{ col: "salary", fn: "mean" },
{ col: "id", fn: "count" },
]);
parser.close();# Trim whitespace and skip bad rows
turbocsv head --trim --skip-errors data.csv
# Fast mode with dynamic typing
turbocsv head --fast --dynamic-typing --format json data.csv
# Run local benchmarks
bun run benchmark
bun run benchmark:compare
# Validate with structured error reporting
turbocsv validate data.csv
# Output: ERROR [TooFewFields] at row 42: Expected 5 fields, got 3
# Process specific range with comments
turbocsv head --from-line 5 --to-line 20 --comments data.csv
# Security: escape formula injection
turbocsv convert --escape-formulae data.csv -o safe.csv
# Handle duplicate headers
turbocsv head --duplicate-headers rename data.csvSee the full API documentation on GitHub.