📊 CSV to JSON Converter

Convert CSV (with a header row) to a JSON array of objects, or a JSON array back to CSV. Handles quoted fields, commas inside quotes, and escaped quotes.

How the CSV is read

The parser walks the text one character at a time, tracking whether it is inside a quoted field. A comma or newline only ends a field or a row when it is outside quotes, and a doubled quote inside a quoted field means one literal quote. The first row becomes the keys:

name,city,note
"Doe, Jane",Boston,"Says ""hi"""

[ { "name": "Doe, Jane", "city": "Boston", "note": "Says \"hi\"" } ]

So the comma inside "Doe, Jane" does not split the row, and the note keeps one pair of quotes rather than two. A newline inside quotes stays in the value, so multi-line cells survive.

What to watch in the output

Switching direction replaces whatever is in the input box with that direction's sample, so copy your text out before you flip the radio button.

Frequently asked questions

How do I handle a comma inside a CSV field?

Wrap the field in double quotes, as in "Doe, Jane". If the value also contains a quote, double it: "Says ""hi""" is read as Says "hi". These are the rules spreadsheets already use when they export.

Why are my numbers quoted in the JSON?

CSV has no types - every cell is text - and this converter does not guess, so a column of prices comes out as strings. That is deliberate: guessing would turn a leading-zero product code like 00734 into 734.

Can it convert JSON back to CSV?

Yes, if the JSON is a non-empty array of objects. The columns are the union of every key seen, in the order they first appear, and missing keys become empty cells. Nested objects and arrays are not flattened - they come out as [object Object] - so flatten them before converting.