Developer guide
How to Convert CSV to JSON (and Back) Without Breaking Your Data
Convert spreadsheet data to JSON and JSON back to CSV correctly: quoted commas, line breaks inside cells, numbers vs text, nested objects and Excel quirks.
By M2Toolkit Editorial TeamPublished 7 min read
Quick answer
Use the first row as keys and turn every following row into an object: name,age / Ada,36 becomes [{"name": "Ada", "age": 36}]. A proper converter must also handle commas inside quotes, line breaks inside cells and numbers vs text — the CSV to JSON converter does all of that.
CSV looks trivial — values separated by commas — which is exactly why so many quick scripts get it wrong. Splitting on commas breaks the moment an address or description contains one. Here's how CSV really works, and what to watch for in both directions.
How CSV actually works
The closest thing to a standard is RFC 4180. Its key rules:
- A field containing a comma, quote or line break is wrapped in double quotes.
- A double quote inside a quoted field is written twice:
"She said ""hi""". - The first row is usually (not always) a header.
name,address,note
"Smith, Anna","12 High St, London","Prefers ""email"""That's three fields per row, not six — which naïve comma-splitting gets wrong.
CSV to JSON: decisions to make
| Decision | Options | Recommendation |
|---|---|---|
| Header row | Use as keys / treat as data | Use as keys when present |
| Types | Everything as text / detect numbers & booleans | Detect, but watch IDs and phone numbers |
| Delimiter | Comma, semicolon, tab | Detect automatically |
| Empty cells | Empty string / null | Empty string is safest |
JSON to CSV: flattening nested data
CSV is flat; JSON often isn't. The common solution is to flatten nested objects into dot-notation columns:
{"name": "Ada", "address": {"city": "London", "zip": "N1"}}
→ name,address.city,address.zip
Ada,London,N1Arrays of simple values can be joined (“a; b; c”); arrays of objects are better kept as JSON text in one column or split into a separate CSV.
Try the free JSON to CSV ConverterFlattens nested objects and quotes values correctly for Excel.Excel quirks
- Everything in one column? Your region uses semicolons as the list separator (common in Europe). Export with a semicolon delimiter.
- Garbled accents? Excel may misread UTF-8 without a byte-order mark. Use Data → From Text/CSV and choose UTF-8, or open the file in Google Sheets.
- Long numbers turned into 1.23E+15? Excel converts long numbers to scientific notation. Import the column as text.
- Dates changed? Excel guesses date formats. Import date columns as text to keep them exactly.
Frequently asked questions
How do I convert Excel to JSON?
Copy the cells from Excel (they paste as tab-separated values) into the CSV to JSON converter — tabs are detected automatically. Or save the sheet as CSV first.
What is TSV?
Tab-separated values: the same as CSV but with tabs as the delimiter. It's what you get when you copy cells from a spreadsheet.