CSV ↔ JSON Converter
Convert comma-separated values to JSON objects and vice versa.
CSV and JSON: two formats that only look simple
CSV is the format everything can export and JSON is the format everything can consume, so converting between them is daily work for anyone who moves data between spreadsheets, APIs and scripts. RFC 4180 describes the common CSV form: one record per line, fields separated by commas, an optional header row, and double quotes around any field that contains a comma, a quote or a line break, with embedded quotes doubled. In practice files arrive with semicolons, tabs, stray byte order marks and ragged rows, which is where a converter earns its keep.
This page uses the PapaParse library in your browser. In CSV to JSON mode the first row becomes the keys and every following row becomes an object, so the output is an array of objects ready for JSON.parse or a REST payload. In JSON to CSV mode an array of objects (or an array of arrays) becomes a header row plus one line per record, with quoting applied wherever a value contains the delimiter, a quote or a newline. Upload a file or paste text; the conversion happens as you type and Swap feeds the output back in as input for a round trip.
What the parser does for you
- Delimiter detection. Comma, semicolon, tab and pipe are detected automatically, so an Excel export from a locale that uses semicolons converts without changes.
- Byte order mark. The invisible BOM that Excel writes at the start of "CSV UTF-8" files is stripped, so the first column name comes out clean instead of prefixed with junk.
- Quoted fields. Commas, doubled quotes and line breaks inside quoted fields are handled as RFC 4180 describes:
"Rao, Ananya"stays one field. - No type guessing. Every value is kept as a string. A PIN code, a phone number written with a leading zero, an account number or a 16-digit card number comes through exactly as written rather than being turned into a number that drops zeros or loses precision.
- Empty lines are skipped, and duplicate header names are made unique with a numeric suffix so no column is silently overwritten.
- Ragged rows (a line with more or fewer fields than the header) are reported as an error rather than being guessed at; fix the source line and paste again.
Going from JSON to CSV
CSV is flat, JSON is not. An array of flat objects such as [{"id": 1, "city": "Hyderabad"}] converts cleanly. Nested objects are not flattened: a value like {"address": {"city": "Pune"}} is written as a placeholder rather than as an address.city column, so flatten records first (or stringify the nested part) if you need those fields in the sheet. Arrays are joined with commas and quoted, null becomes an empty cell, and numbers and booleans become plain text because CSV has no types. Keep the keys of every object identical and in the same order so the header row matches every line. The output uses CRLF line endings, which is what RFC 4180 specifies and what Excel expects.
Excel will change your data
Most damage to CSV files happens when someone opens them in a spreadsheet and saves. Excel drops leading zeros, keeps only 15 significant digits (so a 16-digit card number ends in 0), turns text such as 1/2 into a date, and writes files in the machine's locale, where the separator may be a semicolon. It also saves plain "CSV" in a legacy encoding that garbles Hindi, Telugu or Tamil text; choose "CSV UTF-8" when saving. If a column must stay text, import it as text in the spreadsheet rather than editing the file to work around the conversion.
Cells that start with = + - or @
A value beginning with=, +, - or @ is executed as a formula when the CSV is opened in Excel or Google Sheets. Attackers use this to run commands or exfiltrate data from exported reports. When you generate CSV from user-supplied data, prefix such values with a single quote or a space, and treat any export you did not create as untrusted.Command-line equivalents for large files
The text boxes are comfortable up to a few megabytes. For bigger exports, or for anything that should be repeatable, use a script:
# Python, no packages needed
python3 -c "import csv, json, sys; print(json.dumps(list(csv.DictReader(sys.stdin)), ensure_ascii=False, indent=2))" < data.csv > data.json
# JSON array of flat objects back to CSV with jq
jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json > data.csv
# PowerShell (Windows)
Import-Csv data.csv | ConvertTo-Json -Depth 3 > data.json
# Miller and csvkit handle huge files and many delimiters
mlr --icsv --ojson cat data.csv
csvjson data.csvPython's csv.DictReader mirrors this tool's behaviour: values stay strings and the header row supplies the keys. Convert types deliberately afterwards, column by column, rather than letting a library guess. When the data is truly tabular and large, a Parquet file or a database table is a better destination than either CSV or JSON.
Privacy
Customer exports usually contain personal data: names, phone numbers, PAN or Aadhaar numbers, addresses. This converter runs entirely in your browser and nothing is uploaded, which makes it safe for such files, but the JSON you copy out is just as sensitive as the CSV you pasted in. Drop the columns you do not need before sharing either version, and never commit real customer exports to a repository. For test fixtures, generate synthetic rows with the Fake Data tool instead.
How to use
- Pick the direction with the CSV to JSON and JSON to CSV buttons at the top of the panel.
- Paste the data into the input box or click Upload File to load a .csv, .json or .txt file from your computer.
- For CSV input, make sure the first line is a header row; its names become the JSON keys. The delimiter (comma, semicolon, tab or pipe) is detected automatically.
- For JSON input, supply an array of flat objects with identical keys, or an array of arrays. Flatten nested objects before converting.
- Read the output as it appears. Errors such as "Too many fields" name the problem row; fix the source and paste again.
- Click Copy to take the result, or Swap to feed the output back in and convert it the other way.
Common use cases
- Turning a CRM or payment-gateway CSV export into JSON for a script or a mock API response.
- Converting a JSON API response into CSV so a finance or operations colleague can open it in Excel.
- Checking that a CSV produced by a data pipeline is well formed before it is loaded into a warehouse.
- Building test fixtures in both formats from the same source rows.
- Preserving leading zeros in phone numbers and account numbers that a spreadsheet would destroy.
- Reading a semicolon-separated export from an ERP system without hunting for the delimiter setting.
Frequently asked questions
Why are all the values strings in the JSON output?
How are commas, quotes and line breaks inside a field handled?
Does it support semicolon-separated or tab-separated files?
What happens to nested objects when converting JSON to CSV?
Why does my first column name start with strange characters?
I get "Too many fields" or "Too few fields". What does it mean?
Is my data uploaded anywhere?
How large a file can I convert here?
Advertisement