How to Convert CSV to JSON
Going from a spreadsheet export to structured JSON your code can use is a common need. Here's how the conversion works.
The mapping
The CSV header row becomes the keys, and each subsequent row becomes an object.
name,age
Alice,30
Bob,25
becomes
[
{ "name": "Alice", "age": "30" },
{ "name": "Bob", "age": "25" }
]
Watch out: everything is a string
CSV has no types — 30 is the text "30", not a number. If you need real numbers or booleans, convert them after parsing.
Parsing pitfalls
- Quoted fields can contain commas and newlines:
"Smith, John". - Escaped quotes appear doubled:
"". - Inconsistent columns across rows cause misaligned data.
Naive splitting on commas breaks on all of these — use a proper CSV parser.
Convert online
Paste your CSV into the CSV to JSON converter (switch to CSV → JSON mode) and copy clean JSON. Then validate or format it with the config validator.
The reverse
Need to export JSON back to a spreadsheet? See how to convert JSON to CSV.
Got a config file to check?
Open the config toolkit →