CSV and JSON Converter
CSV to JSON detects the delimiter and header row and outputs objects or arrays; JSON to CSV takes the union of keys as headers and quotes fields containing the delimiter or newlines.
CSV and JSON are the two most common formats for exchanging data: CSV suits tables and bulk import, understood by Excel and most database import tools, while JSON suits APIs and configuration files. This tool converts in both directions — an exported report into a structure an API can accept, or an API's array into a table that opens directly.
What goes wrong most often is delimiters and quoting: a comma, newline or quote inside a field has to be wrapped in double quotes per RFC 4180, with internal quotes doubled, or one row is split into several columns. And garbled non-ASCII characters are usually not the file's fault but a spreadsheet reading UTF-8 as the local encoding, which is fixed by choosing UTF-8 explicitly on import.
Did this tool solve your problem?
Submitting sends the tool name, your input and the current result to the server. Please do not include ID numbers, phone numbers or other private data.
AI assistant It answers using your current input and result
Asking again sends your current input and result to the server once more. Please do not include private data.
How to use
- Choose the direction: CSV to JSON, or JSON to CSV.
- Paste the input; the delimiter and header row are detected.
- Check that fields containing commas or newlines are quoted.
- Choose UTF-8 explicitly when opening the CSV in a spreadsheet.
How it works
What makes CSV parsing hard
CSV looks like splitting each line on commas, but real files hide commas inside field values and even newlines inside fields. A parser must therefore be a state machine: a quote opens the inside-quotes state where commas and newlines do not separate; a doubled "" inside quotes means one literal quote; only commas outside quotes split fields.
Automatic delimiter detection
Detection: take the first few rows and count each candidate delimiter (comma, semicolon, tab, pipe) outside quotes, preferring the one that appears consistently in every row and most often. If none appears (single-column data), fall back to comma. You can also fix the delimiter manually, in which case parsing follows it exactly.
Header rules when JSON becomes CSV
JSON to CSV: the header is the union of all object keys in first-appearance order, and missing keys leave empty cells. For arrays of arrays (no keys), output goes through as-is without a header. Field values containing delimiters, quotes or newlines get quoted automatically with quotes doubled, so Excel opens the result directly.
Code example
Python Reading and writing CSV with the standard library
import csv, json
# CSV to JSON (handles quotes and newlines inside fields automatically)
with open("in.csv", newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f))
with open("out.json", "w", encoding="utf-8") as f:
json.dump(rows, f, ensure_ascii=False, indent=2)
# JSON to CSV
with open("out.csv", "w", newline="", encoding="utf-8-sig") as f:
w = csv.DictWriter(f, fieldnames=rows[0].keys())
w.writeheader()
w.writerows(rows)
Shell Converting on the command line and checking fields
# Field names of the first object (to confirm the header)
jq -r ".[0] | keys[]" out.json
# Keep only the columns you need, as standard CSV
jq -r ".[] | [.id, .name] | @csv" out.json > slim.csv
# Convert to tab-separated (pastes into Excel without column mix-ups)
jq -r ".[] | [.id, .name] | @tsv" out.json > out.tsv
FAQ
How is the CSV delimiter auto-detected?
Take the first 5 rows, count commas, semicolons, tabs and pipes outside quotes, and pick the most frequent one that appears consistently per row. Quoted commas inside content do not mislead it; single-column data falls back to comma.
Is the first row a header or data?
Choose yes and the first row supplies keys, yielding an object array [{"name":"Alice"}]; choose no and it is data too, yielding arrays of arrays [["Alice"]]. Unsure? Check whether the first line holds field names or a real record.
Are commas and newlines inside quotes handled correctly?
Yes. Inside double-quoted fields, commas and newlines are ordinary characters, never separators. A doubled "" inside quotes means one literal quote: he said ""hello"" parses to he said "hello".
Where does the JSON-to-CSV header come from?
The union of all object keys in first-appearance order. [{"a":1},{"b":2}] yields header a,b with row one 1, and row two ,2 with gaps empty. Arrays of arrays have no keys and pass through without a header.
Do numbers become strings?
CSV has no types, so CSV to JSON emits values as strings ("28", not 28). Convert types on import or in code as needed. That is an inherent limitation of CSV, not a conversion bug.
What size is supported?
About 5,000 rows and 200 columns; beyond that you get a notice. The cap keeps conversion instant since it runs synchronously in the browser, and huge tables would freeze the UI. For very large tables use CLI tools like csvkit in batches.
Will Chinese or special characters corrupt?
No. Everything is processed as UTF-8 strings, so Chinese and emoji survive intact. When opening CSV output containing Chinese, older Excel versions need the UTF-8 encoding option. That is an Excel import setting, not a file problem.
Is the data uploaded to a server?
No. Parsing and conversion happen entirely in the browser with no network requests, so the server never sees your table. No history is written either; closing the page clears it. Business data is safe here.