Skip to content

CSV to JSON Converter

Convert between CSV and JSON, RFC 4180 correct.

Convert in either direction. The result replaces the other box.

Results

Paste CSV or JSON, then convert. Your data stays on this device and is never sent anywhere.

How the CSV to JSON converter works

CSV to JSON reads the first record as the header row and turns every record after it into one JSON object, keyed by the matching header name. Parsing follows RFC 4180: a field that opens with a double quote is a quoted field, and inside it commas, carriage returns, line feeds, and the escaped quote "" are all treated as data. An unquoted field is taken verbatim with no trimming, and a comma or a line break (\n, \r, or \r\n) ends it. A short record leaves any missing trailing columns as "", and columns beyond the header are ignored.

JSON to CSV runs the same rules in reverse. The header is the union of every key across all rows, in first-seen order, so rows with different shapes still line up. A field is quoted only if it contains a comma, a double quote, a CR, or an LF, and embedded quotes are escaped by doubling. Missing keys, null, and undefined all become "". The header and records are joined with CRLF, and there is no trailing newline.

Worked example

Convert these two JSON rows to CSV. Note that the second row has an extra city key:

  • { "name": "Smith, John", "age": "42" }
  • { "name": "Lee", "age": "30", "city": "Paris" }

Steps the converter takes:

  1. Build the header as the union of keys in first-seen order: name, age, city.
  2. Row 1: name is Smith, John, which contains a comma, so it is quoted as "Smith, John". There is no city key, so that cell is empty.
  3. Row 2: no field needs quoting, and city is Paris.
  4. Join the header and both records with CRLF.

The result (shown with , as the column separator and each line on its own row):

Line Content
Header name,age,city
Row 1 "Smith, John",42,
Row 2 Lee,30,Paris

Convert that CSV back and you get the same logical rows, with the empty city cell in row 1 read as "".

How to use it

  • Paste CSV to get a JSON array of objects, or paste a JSON array of objects to get CSV back.
  • Make sure your first CSV row is the header. Those names become the JSON keys exactly as written, including case and spaces.
  • Wrap any value containing a comma, a quote, or a line break in double quotes, and double any quote inside it ("").
  • For JSON input, you do not need every object to share the same keys. The writer fills the gaps with empty cells and keeps the column order stable.

Limitations

This converter handles the structure of CSV and JSON, not the meaning of the data. Every CSV field becomes a JSON string, so numbers, booleans, and dates are not detected or cast for you, and leading zeros are preserved rather than dropped. Nested JSON objects and arrays are not flattened into columns, since CSV is a flat grid. Duplicate header names are kept rather than dropped: the first stays as-is and later repeats are suffixed (a, a_2, a_3), so every column survives. The tool assumes comma-delimited input; semicolon or tab files need to be adjusted first.

Frequently asked questions

What happens to a field that has a comma inside it, like a full address?

Quote the whole field with double quotes in the CSV, for example "Smith, John". The parser then reads the comma as data, not as a column break, and stores the value with the comma intact. When writing CSV back out, any field containing a comma is automatically wrapped in quotes for you.

How do I put a double quote character inside a value?

Write it twice. Inside a quoted field, the sequence "" means one literal quote, so 6"" rail produces 6" rail. This is the RFC 4180 escaping rule, and the writer applies it in reverse: every quote in your data is doubled and the field is wrapped in quotes.

My rows do not all have the same keys. What does the CSV header look like?

The header is the union of every key across all rows, listed in the order each key first appears. If a row is missing one of those keys, that cell is written as an empty string. No row is dropped and no key is silently lost.

Does a blank line at the end of my CSV create an empty record?

No. A single trailing newline is treated as the end of the last record, not the start of a new one, so it does not produce a phantom empty row. Internal blank lines inside a quoted field are preserved as data.

Why are values still strings after converting CSV to JSON?

CSV has no type information, so every field is kept as a string to avoid guessing. The text 007 stays "007" rather than becoming 7, and a value like 1.0 is not silently changed. You can cast specific columns to numbers or booleans afterward if you know they should be.