CSV to JSON Converter
Convert between CSV and JSON formats
From spreadsheet rows to an array of objects
CSV suits spreadsheets; JSON suits APIs and code. The trip between them comes up when you feed records into a script, seed a database, or mock an API from data you already have. This tool converts in both directions: CSV rows become an array of objects, and a JSON array of objects flattens back into CSV. In CSV mode it reads the header row as keys and turns each row below into one object, the shape most JavaScript and most APIs expect.
The shape you get, and the keys
The output is a pretty-printed array with two-space indentation, each row an object whose keys come from the CSV headers. Headers get trimmed of surrounding whitespace, interior spaces survive as written, and a blank header falls back to a positional name like col0 or col1 so no data goes missing. A duplicate header is the trap here: JSON keys must be unique, so a second column with the same header silently overwrites the first. Rename duplicate columns before converting. And if your data has no header row, untick First row is headers to get an array of arrays instead.
How each value is typed
Every value comes out as a string. The converter copies each cell as text and leaves typing to you:
- 95000 arrives as "95000" and true as "true". Nothing gets guessed into a number or boolean behind your back.
- Leading zeros in ZIP codes and product IDs survive untouched, which auto-typing converters tend to destroy.
- An empty or missing cell becomes an empty string, not null.
- Dates stay strings, since JSON has no date type anyway.
Where you know the schema, cast in code after the fact, for example rows.map(r => ({ ...r, salary: Number(r.salary) })).
Shaping the output
- Can I get an object keyed by ID instead of an array?
- Not from the tool. Transform the array in code: in JavaScript, Object.fromEntries(arr.map(r => [r.id, r])) rekeys it by id.
- Why do my numbers come out as quoted strings?
- All values do, by design. The tool never guesses types, which protects IDs, ZIP codes, and anything with leading zeros. Convert the fields you know are numeric in code once the data is loaded.
- Can I go the other way, JSON to CSV?
- Yes, switch to JSON to CSV mode. It flattens nested objects into dot-notation columns like user.name, writes arrays as their JSON text, and collects headers across every object so keys that appear only in later records still get columns. A single object becomes a one-row CSV.
- Can I get minified JSON on one line?
- The output is pretty-printed for reading. For a single line, paste it into a minifier or call JSON.stringify on the parsed value with no spacing argument in code.