You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A powerful Node.js library for parsing and writing CSV files with typed column definitions. CSVT-Parse provides comprehensive type validation and robust error handling for working with structured CSV data.
Features
🎯 Typed Column Definitions: Define column types directly in the CSV header (name:string,age:number)
🔍 Comprehensive Type Validation: Built-in validation for 20+ data types including primitives, dates, URLs, emails, UUIDs, and more
🔧 Enum Types: Define columns with restricted value sets (status:enum(pending,approved,rejected))
🔀 Union Types: Support multiple types per column (value:string|number|boolean)
🌟 Any Type: Auto-detecting flexible type that infers the best match (data:any)
📁 File I/O Support: Read from and write to files with async/sync APIs
🛡️ Error Handling: Comprehensive error reporting with line and column context
🚀 High Performance: Optimized parsing with minimal overhead
📦 TypeScript First: Full TypeScript support with complete type definitions
🔒 Source Protection: Obfuscated distribution for commercial use
try{constresult=csvt.parseCSVTSync(content,{strict: true});}catch(error){if(errorinstanceofcsvt.ValidationError){console.log(`Error in column "${error.column}" at line ${error.line}`);console.log(`Expected: ${error.expectedType}, Got: ${error.actualValue}`);}}
Options
constoptions={delimiter: ',',// Field delimiterquote: '"',// Quote characterescape: '"',// Escape characterskipEmptyLines: true,// Skip empty linestrim: true,// Trim whitespacestrict: false,// Strict error handlingprocessEscapes: false// Process escape sequences in string fields};
Escape Sequence Processing
When processEscapes: true is enabled, the following escape sequences are processed in string fields:
Sequence
Result
Description
\\n
\n
Newline character
\\t
\t
Tab character
\\r
\r
Carriage return
\\"
"
Quote character
\\\\
\
Backslash character
Important Notes:
Escape processing only applies to string type fields
For union types, processing applies only if the final parsed value is a string
Complex types like json and array are not affected by escape processing
Default behavior preserves literal backslashes for compatibility