What the CSV to JSON converter does
The converter reads a CSV table and writes each data row as a JSON object, with the header row supplying the keys. It reads the file the way RFC 4180 (opens in a new tab) describes: a quoted cell may contain the delimiter, line breaks and doubled quotes, and rows may end in CRLF, LF or CR. The JSON is written out as text, so a header named __proto__ is an ordinary key and every number keeps the digits it had in the file.
How to convert CSV to JSON
- Paste the table, or open or drop a
.csv,.tsvor.txtfile exported from a spreadsheet or a database. - Leave Delimiter on Detect, or choose it when the summary under the output names the wrong one.
- Check the column types in the preview. Turn off Type inference when every value should stay a string, as for product codes.
- Pick the Output format, then copy the JSON or download it. Swap direction sends the result to JSON to CSV.
Examples
Input
id,name,zip,active
1,Ada,00123,TRUE
2,Linus,94016,false
Output
[
{
"id": 1,
"name": "Ada",
"zip": "00123",
"active": true
},
{
"id": 2,
"name": "Linus",
"zip": "94016",
"active": false
}
]
Input
product;price;sku
Tea;1,5;12345678901234567890
Output
[
{
"product": "Tea",
"price": "1,5",
"sku": 12345678901234567890
}
]
Input
a,b
1,2,3
4
Output
[
{
"a": 1,
"b": 2,
"_3": 3
},
{
"a": 4,
"b": null
}
]
How the delimiter is detected
With Detect, the converter reads the first ten rows with each candidate, a comma, a semicolon, a tab and a pipe, and keeps the one that splits every row into the same number of cells, at least two. Quoted cells count as one cell during the test, so a comma inside "Doe, Jane" does not mislead it. The summary under the output names the delimiter that was used.
Regional settings explain most semicolon files: where the comma is the decimal mark, Excel writes 1,5 for one and a half and separates cells with semicolons instead. A file of a single column has no delimiter to find; it is read with commas and a warning, which you can ignore for a one-column list.
Header rows
The first row names the keys. A header cell that appears twice gets a number, so email, email becomes email and email_2, and an empty header cell becomes column_3 for the third column, each with a warning. If the file starts directly with data, turn off Header row: the keys are then column_1, column_2 and so on, or choose Array of arrays as the Output to get each row as a plain list.
Why a zip code stays text
Type inference decides once per column. A column turns into numbers only when every filled cell is a valid JSON number, and into true and false only when every filled cell is one of those words, in any case, as Excel writes TRUE and FALSE. One cell that does not fit keeps the whole column as text, so the zip code 94016 stays a string beside 00123, and a column never mixes numbers with strings.
Numbers are copied as written. 00123, +1, 1. and 1,5 are not JSON numbers and stay strings, while 1e3 and -0 are written exactly like that. A whole number above 9,007,199,254,740,991 is kept in full, with a note: most JSON readers round it, which the JSON Formatter explains. For ID columns, turning off Type inference is the safer choice.
Nested JSON from dotted headers
With Unflatten keys on, a header such as user.name puts its value inside an object: {"user": {"name": "Ada"}}. Headers that end in .0, .1 and onward to one less than their count build a list, so tags.0 and tags.1 become "tags": ["x", "y"]; numbers with a gap, like .1 and .2 alone, build an object instead. When one header is both a value and a parent, as with a and a.b, neither can be nested: both stay flat keys and the Problems list says so. The Key separator sets the character that splits the headers.
Rows with missing or extra cells
Rows exported by hand-written scripts are not always the same length. A short row gets null for each missing cell. A long row keeps its extra cells under keys named after their position, like _3 for the third column, and only that row has them. Every such row is listed under Problems with its line number, so a stray delimiter is easy to find.
Accents and file encodings
An opened file is read as UTF-8 first. When its bytes are not valid UTF-8, it is read again as Windows-1252, the encoding Excel uses for "CSV (Comma delimited)" files on Windows, and a warning appears under the input. That turns the byte E9 into é and 80 into the euro sign instead of replacement characters. Files saved as "CSV UTF-8" start with a byte order mark, which the converter skips.
JSON array or JSON Lines
A JSON array suits most uses: an API body, a fixture, a configuration. JSON Lines writes one object per line with no surrounding brackets, which log processors, BigQuery and many streaming tools read one line at a time; its download is a .jsonl file. Array of arrays keeps the table's shape, with the header as the first list.
Options
| Option | Values | Default | When to change it |
|---|---|---|---|
| Delimiter | Detect, Comma (,), Semicolon (;), Tab, Pipe (|) | Detect | Choose the delimiter yourself when detection picks the wrong one, for example in a file with very few rows. |
| Header row | On, Off | On | Turn it off for files without a header; the keys become column_1, column_2 and so on. |
| Type inference | On, Off | On | Turn it off to keep every value a string, which suits IDs, product codes and phone numbers. |
| Output | JSON array, JSON array, minified, JSON Lines, Array of arrays | JSON array | JSON Lines for log and data pipelines, arrays of arrays to keep the table's shape. |
| Empty cells | null, Empty string (""), Leave the key out | null | Leave the key out for sparse records; in a list, an empty cell is always null. |
| Unflatten keys | On, Off | Off | Builds nested objects and lists from headers like user.name and tags.0. |
| Key separator | Dot (.), Slash (/), Underscore (_) | Dot (.) | The character that splits headers when Unflatten keys is on. |
| Parse JSON in cells | On, Off | Off | Cells that start with { or [ and hold valid JSON become objects and lists, numbers kept as written. |
| Remove spreadsheet-safe prefix | On, Off | Off | Takes off the apostrophe a spreadsheet-safe export puts before text like =SUM(A1). A value that really started with that apostrophe loses it too. |
| Skip empty lines | On, Off | On | Turn it off to keep each empty line as a row of empty cells. |
Common errors and fixes
| Code | What it means | How to fix it |
|---|---|---|
CSV_Error | A cell opens a double quote that never closes, so the rest of the file would be one cell. | Close the quote, or write a quote inside a cell as two quotes, "". |
CSV_Warning | Text follows a closing quote, as in "5" screen, where the quote was meant as inches. | Double the inner quotes: "5"" screen". The converter keeps the text but warns. |
CSV_Warning | A row has more or fewer cells than the header, often from an unquoted delimiter inside a value. | Quote the value that contains the delimiter, or add the missing cells. |
CSV_Warning | No delimiter splits the first rows into two or more columns: the file has one column, or very few rows. | Ignore it for a one-column list; otherwise choose the Delimiter. |
CSV_Warning | The file is not UTF-8, so it was read as Windows-1252. | Check a few accented words. If they are still wrong, export the file again as CSV UTF-8. |
CSV_Warning | Two columns have the same name, which would make one key hide the other. | Rename one of them in the header, or keep the numbered name the converter gave it. |
CSV_Warning | A header cell is empty, often a leftover first column of row numbers. | Name the column, or keep the column_N key it was given. |
CSV_Warning | With Unflatten keys, one header is both a value and the parent of another, like a and a.b. | Rename one of the headers, or turn off Unflatten keys. |
CSV_Note | Cells start with an apostrophe before =, +, - or @, the mark of a spreadsheet-safe export. | Turn on Remove spreadsheet-safe prefix to get the original values back. |
CSV_Note | The file has a header row and nothing below it. | Check that the right file was opened; the output is an empty array. |