CSV to JSON Converter
Convert CSV data to JSON with support for formatting, type inference, and clean output.
Converts CSV — exported from Excel, Google Sheets or a database — into a JSON array of objects, with numbers and booleans typed correctly. Conversion runs in your browser; the data is not uploaded.
Options
- CSV delimiter — left empty, it is detected from the data and named under the field. To set it, type a single character such as
;or|, or\tfor a tab. - Header included — on by default: the first row names the keys. Off, keys are
column,column_2and so on; repeated header names get the same numbering. - Trim values — removes spaces around each value; on by default.
- Auto type inference — on by default (see below). Off, every value stays a string.
- Use null for empty values — empty cells become
nullinstead of"". - Nest dotted headers — off by default. On, a header such as
address.cityputs its value inside anaddressobject, the reverse of flattening in the JSON to CSV converter. A header stays as written when it has an empty part (a..b) or when another column already holds a plain value under the same key (abesidea.b). Parts that are numbers are keys, not array positions. - JSON format — pretty with 1 to 8 spaces of indent, or minified.
Download saves the output as data.json.
How values are read
Detection tries a comma, a semicolon, a tab and a pipe on the first 20 rows and takes the one that splits every row into the same number of values, more than one; delimiters inside quotes do not count. When two qualify, the one giving more columns wins, then the earlier in that list. For a file with uneven rows it takes the one that splits the first row furthest, and a comma when nothing splits it. A first line of sep=;, which Excel writes to name the delimiter, sets it and is not read as a row.
Values in double quotes may contain the delimiter and line breaks, and a doubled quote inside stands for one quote. A quote opens a quoted value only at the start of a value, after any spaces; anywhere else, as in 5" disk, it is an ordinary character. A quoted value that is never closed is reported with the line it opened on. Blank lines between rows are skipped, and a byte order mark at the start of the file, as Excel writes, is ignored. Extra values beyond the header's columns are dropped; missing ones become empty.
With type inference, true, false and null become JSON values, plain numbers become numbers written digit for digit — long IDs are not rounded — and values that are valid JSON arrays or objects are parsed. Numbers with a leading zero, like ZIP codes and phone numbers, stay strings so the zeros are kept.
Examples
Quotes, types and empty cells
With the default options:
- CSV
id,name,zip,active,score,tags 1,"Sharma, Anna",0012,true,4.5,"[""a"",""b""]" 2,Ben,,false,,
- JSON
[ { "id": 1, "name": "Sharma, Anna", "zip": "0012", "active": true, "score": 4.5, "tags": [ "a", "b" ] }, { "id": 2, "name": "Ben", "zip": "", "active": false, "score": "", "tags": "" } ]
A value across two lines
- CSV
id,address 1,"12 High Street London"
- JSON
[ { "id": 1, "address": "12 High Street\nLondon" } ]
Three lines of CSV, two rows: the line break inside the quotes belongs to the value, written \n in JSON.
Semicolons and dotted headers
With Nest dotted headers on and the delimiter left empty:
- CSV
name;price;address.city;address.pin Anna;1,5;Pune;411001
- JSON
[ { "name": "Anna", "price": "1,5", "address": { "city": "Pune", "pin": 411001 } } ]
The semicolon is detected: a comma would split only the second row. 1,5 stays text, since a decimal comma is not a JSON number.
See also
- JSON to CSV Converter — for the reverse conversion.
- JSON Schema Validator — to check the converted data against a schema.