CSV to JSON Converter

Turn a CSV file into a JSON array of objects, with type detection and a custom delimiter.

0 characters

Or drop a .csv/.txt file onto the box above.

Delimiter
Rows
Indent

How to use

  1. Paste CSV, with or without a header row.
  2. Pick the Field separator if it is not a comma (semicolon and tab are common exports from European Excel and TSV files).
  3. Leave First row is a header on to get an array of objects; untick it for an array of arrays.
  4. Detect numbers, booleans and blanks turns "28" into 28 and an empty cell into null; untick it to keep every value as text.
  5. Copy to clipboard, or Download .json.

Why a real parser instead of splitting on commas

CSV looks simple enough to parse with line.split(',') until a field itself contains a comma: a full name like "Hopper, Grace", an address, or a quoted number with a thousands separator. RFC 4180 handles this by allowing a field to be wrapped in double quotes, inside which a comma, a line break, or an escaped "" are all just part of the value. A naive split breaks on all three.

This tool implements that quoting rule directly (not a regular expression, which cannot correctly track "am I inside quotes right now" across a comma or a newline) and turns each row into a JSON object keyed by the header, or a plain array if your CSV has no header row. Going the other way, the JSON to CSV Converter turns a JSON array back into a spreadsheet-ready file.

Example

This CSV, including a value that itself contains a comma:

name,age,city
Ada Lovelace,28,London
"Grace Hopper, PhD",85,"New York, NY"

becomes:

[
  {
    "name": "Ada Lovelace",
    "age": 28,
    "city": "London"
  },
  {
    "name": "Grace Hopper, PhD",
    "age": 85,
    "city": "New York, NY"
  }
]

Options explained

Edge cases and common errors

Do the same thing in code

import csv, json

with open("data.csv", newline="") as f:
    rows = list(csv.DictReader(f))
print(json.dumps(rows, indent=2))

Python's csv module handles the same RFC 4180 quoting rules but keeps every value as a string, and you would add your own number/boolean conversion to match this tool's "Detect numbers, booleans and blanks" option. In the browser, the closest widely-used equivalent is the PapaParse library.

CSV to JSON Converter FAQ

Does it handle commas and quotes inside a field?

Yes. A field wrapped in double quotes may contain the delimiter, a line break, or an escaped quote written as "", following RFC 4180. "line one\nline two" in a single cell becomes [{"note":"line one\nline two"}] rather than being split into two rows.

Why does a ZIP code like 00501 stay in quotes in the JSON?

Number detection deliberately skips values with a leading zero, because converting "00501" to 501 would silently discard a real digit. zip\n00501\n90210 becomes [{"zip":"00501"},{"zip":90210}]: the first ZIP stays text, the second becomes a number, matching how each one is actually meant to be used.

What happens with duplicate column names?

The last column with that name wins for each row, the same way a JavaScript or Python object handles a repeated key. a,a\n1,2 becomes [{"a":2}], not an array of two values. Rename duplicate columns before converting if you need both.

What if my CSV has no header row?

Untick First row is a header and every row becomes an array instead of an object: 1,2\n3,4 becomes [[1,2],[3,4]].

Runs entirely in your browser: this page is a static file with no server behind it, so nothing you paste can be uploaded. Last reviewed by Parthesh Gupta. Implements RFC 4180 (CSV).