CSV to JSON
Convert CSV data to a JSON array — auto-detects delimiter, handles quoted fields.
[
{
"name": "Alice",
"age": 30,
"city": "New York",
"active": true
},
{
"name": "Bob",
"age": 25,
"city": "London",
"active": false
},
{
"name": "Carol",
"age": 35,
"city": "Tokyo",
"active": true
}
]How CSV to JSON conversion works
The first row of your CSV is treated as the header row — its values become the JSON object keys. The delimiter is auto-detected by sampling the first line (comma, tab, semicolon, and pipe are all supported), or you can override it with the buttons above. Quoted fields (including those containing the delimiter or newlines) are handled per RFC 4180. Numbers, booleans (true/false), and null are automatically coerced to their native JSON types; everything else stays a string.
To go the other way, use the JSON to CSV converter. For tabular data in other formats, try CSV to YAML or JSON Formatter to validate and prettify the output.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Turning a spreadsheet export into the JSON an API or a script expects.
- Producing a fixture from real tabular data.
- Checking how quoted fields and embedded commas parse before writing an importer.
- Converting a data extract for a tool that cannot read CSV.
- Getting a structured view of a file whose columns are hard to line up visually.
How it works in practice
A worked example
A spreadsheet export needs to become JSON for a script, and the file has postcodes and long order references in it.
sku,zip,qty,active,ref A-1,01234,7,true,9007199254740993
[
{
"sku": "A-1",
"zip": 1234,
"qty": 7,
"active": true,
"ref": 9007199254740992
}
]Types are inferred, always, and two of those five values are now wrong. The postcode lost its leading zero because it reads as a number and a number has no leading zeros. The reference lost its final digit because these are floating-point doubles and anything past nine quadrillion rounds to the nearest representable value. Neither produced a warning and neither is recoverable from the output. The first field stayed text only because it cannot be read as a number, and the flag became a real boolean because it can.
The edge case that catches people
Quoting the field in the source does not opt out of any of that. The quotes do their job first — protecting delimiters and newlines while the row is parsed — and coercion then runs on the value that comes out, so a quoted postcode is treated exactly like an unquoted one. A field containing the word null becomes a JSON null either way, and a hexadecimal literal becomes its decimal value, because the language considers that a number too. If a column has to survive as text, the place to fix it is downstream.
When not to use this tool
For a pipeline that has to be right, this is the wrong layer. Looking at the shape of an unfamiliar file is exactly what it is for; an import that matters wants a parser you can configure — column types declared rather than guessed, an error when a value does not fit them, and a switch for a file with no header row. Python's csv module and any competent database loader both give you that. Here the guessing is the feature, it is not optional, and the first row is always treated as the header.
Frequently Asked Questions
- How does the tool detect my CSV delimiter?
- It counts commas, semicolons, tabs and pipes that fall outside quoted sections, across the whole input, and takes the most frequent — falling back to a comma when none of them appears. Override it with the dropdown when the guess is wrong, which happens on files with one column.
- What if my CSV has no header row?
- The first row is always treated as the header, and there is no option to turn that off — so a file without one loses its first record to the key names. Add a header row before converting, or use a parser you can configure if the files arrive that way routinely.
- How are quoted fields with embedded commas handled?
- The parser follows RFC 4180: fields wrapped in double quotes may contain commas and newlines. Escaped quotes ("") inside a quoted field are decoded to a single double quote.
- Can I parse CSV files with accented or special characters?
- Yes. The converter handles UTF-8 text including accented characters, CJK, Arabic, and emoji. Drag-drop or paste your file directly — no encoding conversion needed.
- What JSON structure does the output use?
- An array of objects, one per row, with keys taken from the header row. Values are coerced to native JSON types automatically and not optionally: numbers, true, false and empty or null become their JSON equivalents, and everything else stays a string.
Common errors and gotchas
- Assuming the first row is a header when the file has none, which silently loses a record.
- Splitting on commas naively, which breaks the moment a quoted field contains one.
- Overlooking embedded newlines inside quoted fields, which a line-based reader treats as new records.
- Expecting numbers and booleans. Every CSV value is text unless something converts it deliberately.
- Ignoring a byte-order mark, which attaches invisible characters to the first column name.