CSV to JSON: Convert Spreadsheet Rows to JSON Objects
By FindMySum · Last reviewed
Use this CSV to JSON converter to turn a spreadsheet export into a JSON array that a program, an API or a database import can read. Paste the CSV above and the JSON appears as you type. The conversion happens in your browser, so customer lists and other private exports stay on your computer.
Where CSV comes from
Almost every spreadsheet, accounting package and admin dashboard can export CSV: plain text, one row per line, values separated by commas. It is easy to produce and hard to read reliably, because the format was never strictly defined. RFC 4180 wrote down the common practice in 2005, and this tool follows it, along with the variations real files use: semicolons and tabs as separators, Windows, Unix and old Mac line endings, and the invisible byte order mark Excel puts at the start of UTF-8 files.
How to use it
- Paste the CSV, or open the file in a text editor and copy everything.
- Keep "First row is the header" on when the first line names the columns. Turn it off to get plain arrays.
- Decide about types. Leaving values as text is the safe choice; detecting numbers is convenient when a column really is numeric.
- Pick how empty cells should appear (an empty string or null), and the indentation.
- Copy or download the JSON.
A worked example
This export has a header, a value with a comma inside quotes, and a postal code with a leading zero:
id,name,postal_code
1,"Hopper, Grace",02134
2,Ada Lovelace,NW1 6XE
With the defaults, the result is:
[
{
"id": "1",
"name": "Hopper, Grace",
"postal_code": "02134"
},
{
"id": "2",
"name": "Ada Lovelace",
"postal_code": "NW1 6XE"
}
]
The quoted comma stayed inside the name. With number detection on, id becomes 1 and 2, while 02134 stays text: as a number it would lose its zero and become a different postal code.
Common mistakes
Letting a tool guess types. Converters that turn every numeric-looking value into a number turn ZIP codes into smaller numbers and long account numbers into rounded ones; spreadsheets famously turned the gene name SEPT2 into a date. Convert only the columns you know are numbers.
Opening and re-saving in a spreadsheet first. Spreadsheets apply their own guesses when they open a CSV file. Convert the original export instead.
Unquoted delimiters. A value such as Smith, John must be in double quotes in a comma-separated file, or it becomes two fields. The ragged-row warning points to the lines where this happened.
To go the other way, the JSON formatter checks JSON before you work with it, and the average calculator is handy for a quick look at a numeric column.