How to convert CSV to JSON
- Choose a CSV or TSV file, or paste CSV text.
- Check the preview. Untick "First row is the header" if your file has none: you then get arrays, or objects with keys "Column 1", "Column 2".
- Pick the shape, value types and layout, then download or copy the JSON.
For a file with the header id,name,active, the default output is:
[
{ "id": 1, "name": "Ann", "active": true },
{ "id": 2, "name": "Bob", "active": false }
]Other ways
In Python: csv.DictReader plus json.dump gives objects with every
value a string. In JavaScript, Papa Parse with header: true does the same, and dynamicTyping: true converts numbers (dropping leading zeros). Excel and Google Sheets
can't save JSON.
Questions
- Are numbers written as numbers or strings?
- With "Numbers, true/false and null typed" (the default), 42 and 3.50 become JSON numbers, true and false become booleans and empty cells become null. Values a number would change stay strings: 02134, +44 20 7946 0958, IDs longer than 15 digits (JavaScript can't hold them exactly). Choose "Everything as text" to get every value as a string, empty cells as "".
- What if two columns have the same name?
- JSON keys must be unique, so the second gets a suffix: name, name_2. Empty headers become "Column 3" and so on.
- Can I get nested JSON?
- Yes: tick "Nest dotted column names" and columns like address.city and address.zip become {"address": {"city": ..., "zip": ...}}; columns tags.0, tags.1 become an array.
- What is JSON Lines?
- One JSON object per line, without the surrounding array (also called NDJSON). Tools such as BigQuery, Elasticsearch and many log pipelines import it, and big files can be read line by line.
- Is the CSV uploaded?
- No. It is converted in your browser; you can also paste the CSV and copy the JSON.
Related tools
- JSON to CSV Converter Convert JSON to CSV online. Nested objects become columns, numbers are kept exactly, and JSON Lines works too. Free; your data never leaves your computer.
- CSV to Excel Converter (XLSX), Keeps Leading Zeros Convert CSV to Excel XLSX online without losing leading zeros, long numbers or dates. Detects the delimiter and encoding. Free; the file stays on your computer.
- Convert CSV, Excel, JSON and XML Files Convert between CSV, Excel, JSON and XML online without losing leading zeros, long IDs or dates. Free; your files are converted in your browser, never uploaded.