Convert a CSV to JSON
Every row an object, every header a key.
- Array, JSON Lines or arrays
- Numbers and booleans detected
- IDs stay strings
- Nothing uploaded
1.Open the file
CSV or TSV. Drag it here, or choose a file.
Why it exists
CSV to JSON looks like the easy direction, and the usual converters make it easy by getting the types wrong: everything becomes a string, or everything that looks numeric becomes a number, including the ZIP code with the leading zero and the 18-digit ID that JavaScript cannot represent exactly. This decides each column from all of its values and leaves the ones that only look like numbers alone.
What it does
- Writes an array of objects keyed by the header row, JSON Lines with one object per line, or an array of arrays with the header first.
- Detects columns that are entirely numbers or true/false and writes them unquoted.
- Keeps columns with leading zeros or more than 15 digits as strings, because a JSON number would change them.
- Turns empty cells into null rather than an empty string, or keeps everything as strings if you prefer.
- Indents for reading, or writes the smallest file possible.
Which shape to pick
An array of objects is what most APIs and JavaScript code expect. JSON Lines suits large files and data tools that stream one record at a time, such as BigQuery, Elasticsearch and jq. An array of arrays is the most compact, and keeps the column order explicit.
Questions
- Why is my ID column still a string?
- Because turning it into a number would change it. A leading zero is dropped by any JSON parser, and integers past 15 or 16 digits lose precision in JavaScript. If every value in a column is a plain number without either problem, it is written as a number.
- What happens to empty cells?
- They become null when type detection is on, since a CSV has no way to tell an empty string from a missing value. With detection off, every value, empty ones included, is a string.
- Can it handle nested JSON?
- CSV is flat, so the JSON it produces is flat: one level of keys per record. Going the other way, from nested JSON to CSV, is what the JSON to CSV tool does.
The other tools
- Open a CSV file in your browserDrop a file in. It opens here, and it stays here.Open it
- Run SQL on a CSV fileReal SQL, on your file, without installing a database.Open it
- Merge CSV files into oneSeveral files in, one file out, columns matched by name.Open it
- Remove duplicate rows from a CSVDuplicates on the columns you say identify a row.Open it
- Compare two CSV filesAdded, removed, changed, matched on a key rather than line by line.Open it
- Convert a CSV to PDFA CSV, laid out as a readable table, saved as a PDF.Open it
- Convert a CSV to ExcelA real .xlsx, with nothing in it changed on the way.Open it
- Convert JSON to CSVA tree, flattened into a table you can open anywhere.Open it
- Convert Excel to CSVEvery sheet of a workbook, out as clean UTF-8 CSV.Open it
- Split a CSV fileOne file too big to use, as several that are not.Open it
- Clean up a messy CSVGermany, germany and “Germany ” become one value again.Open it
- Convert a CSV to SQL INSERT statementsA CSV in, a .sql script any database will run.Open it