🔄
DeveloperFree · In-Browser
CSV to JSON Converter
Convert CSV to JSON and back, with quoted fields handled properly.
Convert CSV to JSON, or JSON back to CSV, with properly quoted fields handled correctly — commas inside a quoted CSV value, or nested JSON structures, are exactly where naive conversions tend to break.
A common step when moving data between a spreadsheet and an API, or preparing exported data for a tool that expects the other format.
Why CSV is harder than it looks
- Commas inside values must be quoted: `"Smith, John",42` is two fields, not three.
- A quote inside a quoted field is escaped by doubling it: `"She said ""hi"""`.
- Values can contain newlines if they're quoted, so you cannot parse CSV by splitting on line breaks.
- There is no standard for the delimiter. Locales using a comma as the decimal separator often export semicolon-separated files.
- Leading zeros and long numbers get mangled by spreadsheets — postcodes and IDs become numbers and lose their zeros.
- Character encoding is not declared in the file. A UTF-8 CSV opened as Windows-1252 shows mojibake.
How nesting is handled
| JSON | CSV column | Value |
|---|---|---|
| {"user": {"name": "Ada"}} | user.name | Ada |
| {"tags": ["a", "b"]} | tags | a,b (quoted) |
| {"a": null} | a | empty |
| {"ok": true} | ok | true |
CSV is flat by nature. Deeply nested or irregular JSON flattens into sparse columns and usually needs a manual pass afterwards.
Frequently asked questions
- What happens to nested JSON objects when converting to CSV?
- Nested objects and arrays are flattened into a sensible column structure where possible; deeply nested or highly irregular JSON may need manual cleanup after conversion.
- Does this handle commas inside quoted CSV fields correctly?
- Yes — the parser respects proper CSV quoting rules, so a comma inside a quoted field isn't mistaken for a column separator.
- Does the first row need to be a header row?
- Yes, for CSV-to-JSON conversion the first row is treated as column headers, which become the keys in each resulting JSON object.
- Why did my ID numbers lose their leading zeros?
- That's a spreadsheet behaviour, not a conversion one — Excel and similar tools interpret 00123 as the number 123. Format the column as text before opening, or keep the data in JSON.
- My CSV uses semicolons instead of commas — will it work?
- Semicolon-delimited files are common in locales where the comma is a decimal separator. Replace the delimiter before converting, or check whether the tool lets you set it.