How to convert CSV to JSON and back
Two formats for the same tabular data. Converting is easy; the quoting rules are where it goes wrong.
CSV is rows and columns as text. JSON is nested and typed. Converting between them is routine, and doing it by splitting on commas is the classic mistake.
Step-by-step
- Paste your data, or load a file.
- Choose a direction.
- Copy or download the result.
Why splitting on commas fails
A CSV field may be quoted, and a quoted field may contain commas, newlines, and escaped quotes. This is a single valid row with two fields:
"Smith, John","He said ""hello"""
Splitting on commas produces four broken fields. A conforming parser is required, and that is what this uses — quoted fields with embedded commas and line breaks come through intact.
Types
CSV has no types; everything is text. Converting to JSON means deciding whether "42" becomes a number and "true" becomes a boolean. Helpful usually, occasionally wrong — a postcode or a phone number with leading zeros must stay a string, or the zeros vanish. Check any column of identifiers after conversion.
The header row
The first row is treated as field names, which is the usual convention. If your file has no header, the first row of data will be consumed as one — check the output rather than assuming.
Frequently asked questions
Does it handle commas inside quoted fields?
Yes. A conforming parser is used, so quoted fields containing commas, newlines and escaped quotes are handled correctly.
Why did my leading zeros disappear?
The column was interpreted as numeric. Identifiers such as postcodes and phone numbers need to stay text — check any such column after converting.
Is there a size limit?
It is bounded by your device's memory rather than an imposed cap, since everything runs locally.
Open the developer tools →