Guides › Text, code, and data
How to convert CSV to JSON and back
Last updated 10 October 2026 · Written by Souren Das
CSV and JSON are the two formats people most often need to move between. A spreadsheet exports CSV; a web app or script wants JSON. Or an API returns JSON and a colleague wants it in Excel. This guide explains how each format represents data, how to convert in both directions with Dev Tools, and where a simple converter breaks so you can avoid broken rows.
How the two formats differ
CSV (comma-separated values) is a table. The first line usually holds column names, and every following line is one row with values separated by commas:
id,name,city
1,Asha,Pune
2,Ravi,Chennai
JSON can describe a table too, as an array of objects where each object is a row and each key is a column:
[
{ "id": 1, "name": "Asha", "city": "Pune" },
{ "id": 2, "name": "Ravi", "city": "Chennai" }
]
The difference is that JSON can also nest: a row can contain a list or another object. CSV cannot. So any JSON with nested values has to be flattened before it fits in a spreadsheet, and CSV values carry no types, so everything is text until a program decides otherwise.
CSV to JSON, step by step
- Export your sheet as CSV. In Excel, use File > Save As > CSV UTF-8. In Google Sheets, File > Download > Comma-separated values.
- Open the file in a text editor and copy its contents.
- Open Dev Tools on the JSON / CSV tab.
- Paste into the CSV Input / Output box.
- Press Convert CSV to JSON. The JSON appears in the JSON box above, pretty-printed. Each row becomes an object, with the header line as keys.
- Check a few rows against the spreadsheet, especially any with commas or quotes in their values.
The converter needs a header line and at least one data row. If there are fewer, it shows "CSV must have at least a header and 1 row".
JSON to CSV, step by step
- Paste your JSON into the JSON Input / Output box. It must be an array of objects, starting with [ and containing { } rows.
- Press Format JSON first if you want to check it is valid.
- Press Convert JSON to CSV. The CSV appears in the CSV box.
- Copy it into a text editor and save it with a .csv extension, then open it in your spreadsheet program.
If the input is not an array, or the array is empty, the page shows "Input must be a non-empty array of objects".
Where a simple converter breaks
This converter is deliberately simple. Knowing its limits avoids silently broken data.
CSV to JSON
- Commas inside values. Each line is split at every comma. A value like "Bengaluru, Karnataka", even in quotes, is split into two cells and every column after it shifts. Replace those commas, or use a spreadsheet's own export to JSON if it has one.
- Line breaks inside values. A cell with a line break becomes two rows.
- Types. Every value comes out as a string, so 42 becomes "42" and TRUE becomes "TRUE". Convert types in your code if they matter.
- Quotes. Quotes at the start and end of a value are removed. Escaped double quotes inside a value ("") are not unescaped.
JSON to CSV
- Columns come from the first object. Keys that only appear in later objects are dropped. Put the most complete row first, or add missing keys with empty values.
- Text values are written in double quotes. Numbers, true, and false are written bare. Spreadsheets read this correctly.
- Nested objects and arrays are written as JSON text inside the cell. Because that text contains its own quotes, spreadsheets may not read the cell cleanly. Flatten nested data before converting.
For anything more complex, such as large exports, quoted commas, or nested data, a spreadsheet's import wizard or a short script with a proper CSV library is the right tool.
Common mistakes
- Semicolon CSV. In some regions Excel saves CSV with semicolons. The converter only splits on commas. Change the separator in your spreadsheet's export settings.
- Garbled Indian-language text in Excel. Open the CSV with Data > From Text/CSV and choose UTF-8, or save as CSV UTF-8 in the first place.
- Leading zeros vanish. Excel turns 007 into 7 and long numbers such as phone numbers into scientific notation when it opens a CSV. Import the column as text.
- Header typos. The header line becomes your JSON keys. "Name " with a trailing space is trimmed, but "First name" with a space stays as is, which may not match what your code expects.
A worked example of a broken row
Take this CSV, where one address contains a comma inside quotes:
name,city,pin
Asha,"Bengaluru, Karnataka",560001
A full CSV parser would read the three values correctly. This converter splits at every comma, so the row becomes four values: Asha, Bengaluru, Karnataka, and 560001. With three headers, the result is {"name": "Asha", "city": "Bengaluru", "pin": "Karnataka"} and the real PIN code is lost. The fix is to replace the comma inside the value, for example with a hyphen, before converting, or to split city and state into their own columns in the spreadsheet. Check one or two rows that contain commas every time.
Privacy
Customer lists and exports are personal data. The conversion runs in your browser tab; nothing is sent to FileTools Kit. Delete the files from your downloads when you are done if they hold personal details.
FAQ
Can I upload a .csv file directly?
No. Open it in a text editor and paste the contents.
Is there a row limit?
No fixed limit, but very large pastes can make the browser slow. Split huge files.
Can it handle tab-separated files?
No. Replace tabs with commas first, provided no values contain commas.
Will the JSON keys keep my column order?
Yes. Keys are added in header order.
Related guides: JSON formatting explained, Base64 explained, compare two versions of a text.
Written by Souren Das, FileTools Kit, Bengaluru. Last updated 10 October 2026. Spotted a mistake or a step that does not match the tool? Email support@filetoolskit.com and I will fix it. See how tools and guides are tested.