What this converter does
CSV is the common export format of spreadsheets and databases: one record per line, values separated by commas. JSON is what most APIs, JavaScript code and NoSQL databases expect. This tool turns one into the other.
With a header row, each line of the CSV becomes a JSON object, and the column names become the keys. Without a header row, each line becomes an array of values. Parsing is done by Papa Parse, a well tested CSV library that handles quoted fields, commas inside quotes and line breaks inside cells.
How to use it
- Choose CSV to JSON (or JSON to CSV for the other direction).
- Paste your data, press Open file to load a
.csvor.tsvfile, or press Sample. - Set the options. The JSON updates as you change them:
- Delimiter: Detect, Comma, Semicolon, Tab or Pipe.
- Output: 2 spaces, 4 spaces or Minified.
- First row is header: objects with named keys when on, arrays when off.
- Convert numbers and true/false: turns
12into a number andtrueinto a boolean. When off, every value stays a string. - Skip empty lines: ignores blank rows, which spreadsheets often add at the end.
- Press Copy or Download to save the result as a
.jsonfile.
The status line shows how many rows and columns were read and which delimiter was detected.
Example
This CSV, with a quoted name that contains a comma:
id,name,email,city,signup_date,active,orders
1,Ada Lovelace,[email protected],London,2024-03-01,true,12
2,"Hopper, Grace",[email protected],New York,2024-04-17,false,3
becomes:
[
{
"id": 1,
"name": "Ada Lovelace",
"email": "[email protected]",
"city": "London",
"signup_date": "2024-03-01",
"active": true,
"orders": 12
},
{
"id": 2,
"name": "Hopper, Grace",
"email": "[email protected]",
"city": "New York",
"signup_date": "2024-04-17",
"active": false,
"orders": 3
}
]
The quotes around “Hopper, Grace” kept the comma inside the name. The ids and order counts became numbers, true and false became booleans, and the dates stayed strings because JSON has no date type.
Values that stay text
Turning every number-like value into a number can damage data. This converter keeps a value as text when converting it would change it:
[
{
"name": "Ada",
"zip": "02134",
"phone": "0207 946 0000"
}
]
The zip code keeps its leading zero. The same rule applies to IDs with leading zeros and to integers longer than JavaScript can store exactly. A price written with a decimal comma, such as 2,50 in a semicolon file, also stays a string, because it is not a valid JSON number.
JSON to CSV
Press JSON to CSV and paste an array of objects. Every key that appears in any object becomes a column, in the order they first appear. With Flatten nested objects on, nested data gets dotted column names:
id,name,address.city,address.zip,tags
1,Ada,London,NW1,"[""admin"",""dev""]"
2,Grace,New York,,
Grace had no zip code, so that cell is empty. The tags array was written as JSON text, with its quotes doubled as the CSV format requires. An array of arrays is written row by row without a header. Press Download to save it as a .csv file that Excel, Numbers and Google Sheets can open.
When rows do not fit
If a row has more or fewer values than the header, the converter still produces JSON and points to the problem by spreadsheet row number, for example “Row 3: Too many fields: expected 2 fields but parsed 3”. Row 1 is the header. A quote that is opened and never closed is reported the same way. Fix the row in your file and paste it again.
Tips
- Check the JSON with the JSON formatter, which can also sort keys and minify.
- Need YAML for a config file? Convert to JSON here, then use the JSON to YAML converter.
- To show the data in a README, the Markdown table generator accepts the same CSV or spreadsheet cells.
- Turn Convert numbers and true/false off when every value must stay a string, for example before importing into a system that does its own typing.
Other ways to convert CSV to JSON
- Python: the built-in csv module’s DictReader reads rows as dictionaries, and json.dump writes them out.
- csvkit: the
csvjsoncommand converts a CSV file to JSON in a terminal. - Excel and Google Sheets have no JSON export. Save as CSV first, then convert it here.
- jq can work the other way, from JSON to CSV, with its
@csvfilter.
Everything happens in your browser. Large files take a little longer, and nothing is uploaded.