By Mian Ali Khalid · Published · How we build and test tools
How to use the csv to array converter
- Paste your CSV text into the box. The default example shows a simple csv to array conversion.
- Choose the delimiter (comma, semicolon, tab, pipe, or a custom character).
- Toggle “First row is header” if the first line contains column names.
- Select output format: array of arrays or array of objects.
- Copy the Result JSON from the output area and use it in your code.
How the parser works
The tool implements a hand‑written RFC 4180 parser. It scans the input character by character, tracking whether it is inside a quoted field. Inside quotes, a doubled double‑quote ("") becomes a single quote, and delimiters or line breaks are treated as literal characters. Outside quotes, the chosen delimiter splits fields, and CRLF or LF ends a row. This approach handles embedded newlines, commas inside quotes, and escaped quotes without relying on regular expressions that can fail on large or malformed input. The csv to array conversion is performed entirely in the browser, so your data never leaves your machine.
Delimiter reference
The delimiter can be one of the common presets or a single custom character. The table shows the internal character used for each preset.
| Preset | Character | Escape sequence |
|---|---|---|
| Comma | , | , |
| Semicolon | ; | ; |
| Tab | \t | \t |
| Pipe | | | | |
Header handling
When First row is header is checked, the first parsed row becomes the property names for an array of objects. If a data row has more columns than headers, extra values are assigned keys Column 1, Column 2, … If it has fewer, the missing properties are set to empty strings. When unchecked, the output is always an array of arrays, including the first row as data. This behavior makes the csv to array tool flexible for both keyed and positional access.
Ragged rows
CSV files often have rows with differing column counts. The parser does not pad or truncate the array of arrays; it reports the maximum column count found and flags Ragged rows: Yes in the summary. In array of objects mode, missing values become empty strings and extra values get generated keys like Column 4. In array of arrays mode, each inner array reflects the exact number of fields parsed for that row. Blank lines are skipped. Repeated header names get a numeric suffix (id, id_2), because a JSON object cannot hold the same key twice. Keys appear in the same order as the header row.
Common use cases
- Convert a spreadsheet export to JSON for a JavaScript application.
- Inspect the structure of a CSV file before loading it into a database.
- Transform CSV logs into an array of objects for filtering in the console.
- Prepare data for charting libraries that expect an array of objects.
- Use the csv to array output as test fixtures in unit tests.
Edge cases and limits
The parser runs in memory. It stops at about 3 MB of input or 2 million cells and says so instead of freezing the page. Empty input returns an error, and so does choosing array of objects without a header row. A file that contains only a header row yields an empty array in object mode. Lines ending with a delimiter produce a trailing empty field. The tool does not detect data types; every value stays a string. If you need numbers or booleans, convert them after the csv to array step. A UTF-8 byte order mark at the start is dropped.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple CSV with header | CSV text: name,age,city / Alice,30,New York / Bob,25,Los Angeles; Delimiter: comma; First row is header: yes; Output format: objects | Total rows: 3; Columns (max): 3; Has header: Yes; Delimiter used: ,; Ragged rows: No |
| Quoted fields with commas and newlines | CSV text: "Product","Description","Price" / "Widget","A ""great"" tool",10.00 / "Gadget","Multi-line / description",20.00; Delimiter: comma; First row is header: yes; Output format: array | Total rows: 3; Columns (max): 3; Has header: Yes; Delimiter used: ,; Ragged rows: No |
| Semicolon delimiter, no header | CSV text: 1;2;3 / 4;5;6; Delimiter: semicolon; First row is header: no; Output format: array | Total rows: 2; Columns (max): 3; Has header: No; Delimiter used: ;; Ragged rows: No |
FAQ
Does the parser support RFC 4180 fully?
Quoted fields, doubled quotes, embedded delimiters, embedded newlines (CRLF, LF and CR) and trailing empty fields are all handled. Comments and escape sequences beyond doubled quotes are not supported. Like Python's csv module, a quote only opens a quoted field at the start of a field.
Can I use a multi‑character delimiter?
No. RFC 4180 defines a single‑character delimiter. The custom field accepts only the first character you type.
What happens if my CSV has a byte order mark (BOM)?
A leading byte order mark (U+FEFF) is removed before parsing, so the first column name stays clean.
Why does the output show empty strings for missing columns?
In object mode, every header gets a property. If a row has fewer fields, the remaining properties are set to empty strings to keep the array shape consistent.
Is my data sent to a server?
No. All parsing happens in your browser. Nothing is uploaded.
Can I convert the other way (array to CSV)?
This tool only converts CSV to arrays. For the reverse direction, convert the JSON to CSV with a JSON to CSV tool.
How do I handle a CSV that uses a different encoding?
Paste the text after opening the file in an editor that can decode it (e.g., VS Code, Notepad++). The tool works on Unicode strings.