CSV Rows to an Array Converter
Convert CSV rows to arrays in JavaScript, Python, PHP, Ruby, Java, C#, Go, Swift, Rust, or JSON. RFC 4180 compliant parser with type inference.
Output will appear here...
About
Malformed CSV parsing causes silent data corruption. A missing escaped quote shifts every subsequent column, propagating errors across thousands of rows. This tool implements a finite-state-machine parser compliant with RFC 4180, handling quoted fields, embedded delimiters, escaped double-quotes (""), and newlines within cells. It infers types - distinguishing NULL, booleans, integers, and floats from strings - then serializes each row into syntactically valid array literals for 10 programming languages. The parser processes input in O(n) time where n is total character count. Note: type inference assumes decimal number formatting (period as separator). Locale-specific formats like 1.234,56 require pre-processing.
Formulas
The CSV parser operates as a finite-state machine with 4 states, processing each character c in the input stream:
Type inference applies pattern matching per field value v:
/^-?\d+$/type(v) = Float if v ā /^-?\d+\.\d+$/type(v) = Boolean if v ā /^(true|false)$/itype(v) = NULL if v ā /^(null|nil|none|)$/itype(v) = String otherwiseWhere v is the trimmed field value after CSV parsing, and delim is the user-selected delimiter character.
Reference Data
| Language | Array Syntax | String Quote | Null Literal | Boolean Format | Trailing Comma |
|---|---|---|---|---|---|
| JavaScript | [...] | Double " | null | true / false | Allowed |
| Python | [...] | Double " | None | True / False | Allowed |
| PHP | array(...) or [...] | Single ' | null | true / false | Allowed |
| Ruby | [...] | Double " | nil | true / false | Allowed |
| Java | new String[]{...} | Double " | null | true / false | Not allowed |
| C# | new []{...} | Double " | null | true / false | Allowed |
| Go | []interface{}{...} | Double " | nil | true / false | Required |
| Swift | [...] | Double " | nil | true / false | Allowed |
| Rust | vec![...] | Double " | None | true / false | Allowed |
| JSON | [...] | Double " | null | true / false | Not allowed |
| Common CSV Delimiters | |||||
| Comma | , - RFC 4180 default. Most common in US/UK locale exports. | ||||
| Semicolon | ; - Default in European Excel exports where comma is decimal separator. | ||||
| Tab | \t - TSV format. Common in database exports and clipboard paste from spreadsheets. | ||||
| Pipe | | - Used when field data contains commas and semicolons frequently. | ||||