How to Convert CSV to JSON
CSV is great for spreadsheets but awkward for code. Converting it to JSON gives you typed, structured data that's easy to work with. Here's how the two map and what to watch for.
How CSV maps to JSON
A CSV's header row becomes the keys, and each following row becomes one object. So this CSV:
name,role
Ada,engineer
Grace,admiral
becomes an array of objects:
[
{ "name": "Ada", "role": "engineer" },
{ "name": "Grace", "role": "admiral" }
]
Each row is a record; each column is a field. That array-of-objects shape is exactly what most APIs and JavaScript code expect.
Rules that matter
- The header row defines the keys. Make sure your CSV has one, and that the names are clean (no stray spaces).
- Quoting — a field containing a comma must be wrapped in double quotes (
"Smith, Jr."); a literal quote inside is doubled (""). - Everything is text. CSV has no types, so
42andtruearrive as strings unless you convert them afterward.
Watch the edge cases
Empty fields, inconsistent column counts, and different line endings are the usual culprits when a conversion looks wrong. Cleaning the CSV first — one consistent header, equal columns per row — avoids most surprises.
The other direction
Need to go back the other way? See How to Convert JSON to CSV, and for choosing between formats generally, JSON vs XML vs YAML vs CSV.
Try it
Paste your CSV and get clean JSON in one click — it runs entirely in your browser, nothing uploaded.