About JSON to CSV
Turning a JSON array into a table is the usual starting point for analysis and reconciliation. An exported order list handed to an operator, an API user listing pasted into a report, records extracted from logs to be counted by column. JSON is naturally nested and a table is flat, so the heart of the conversion is deciding what to do with the nested layer. The mechanism treats each element of the array as a row and each key as a column. Top-level keys become columns directly, and nested objects or arrays are handled in one of three ways: serializing the nested structure as JSON text inside a single cell, flattening it into dotted column names such as address.city, or exploding the array into multiple rows as a Cartesian product. Each strategy has costs, and the wrong choice corrupts the downstream counting. Practical notes: First confirm whether every element has the same keys. Real data often omits fields on some elements, in which case the union of keys is the complete column set with gaps left empty. Inferring columns from the first element silently drops later fields, a problem that surfaces only during reconciliation. Agree on delimiter and quoting too: CSV fields containing the delimiter, a quote or a newline must be wrapped in double quotes with inner quotes doubled. Comma is not the only option, and tab-separated output is often easier when the data itself contains commas. Limits you need up front. Encoding decides whether non-Latin text survives: export UTF-8 with a byte order mark or Excel on a localized Windows install opens it with the local code page and shows mojibake. Long numbers get mangled by spreadsheet software, since an eighteen-digit order number imported into Excel loses its last digits; export that column as prefixed text or use a real spreadsheet format instead. CSV also carries no type information, so leading zeros in postal codes or employee numbers disappear and a value reading 2026-10-01 may be auto-converted into a date with a different display format. Data and privacy: what gets tabulated here is typically a user listing, order records or access logs, batch data full of personal information at scale. This tool parses and exports in the browser without uploading file contents. Process customer data locally or inside your own network, and after exporting confirm the table does not contain fields that should have been masked. Prepare for scale as well: a few tens of thousands of rows are quick in the browser, while millions belong on the command line or in a database export, because the tabular format is neither efficient nor easy to validate at that size. Exporting in chunks and concatenating with a script is a workable compromise, provided every chunk uses identical column names, since mismatched headers produce misaligned columns that tend to surface only during reconciliation, costing far more than the extra minutes spent at export time. If the downstream target is a data warehouse, freeze the column list before export and confirm it with the receiving side once. Afterwards the upstream may only add fields, never restructure columns, so nothing changes after reports have already been built on the current shape. After exporting, spot-check the first and last rows plus the total count before handing the file downstream, which catches the two most common problems, truncation and misaligned columns, before they propagate. The most common misuse is inferring columns from the first element only, which silently drops fields unique to later ones, a problem usually discovered during reconciliation. Another is using a comma delimiter while the data itself contains commas: columns shift without the row count changing, which is harder to spot than missing rows. When a downstream consumer reads the file repeatedly, freeze the column list and confirm it once.
How It Works Internally
Conversion treats each array element as a row and each key as a column. Nested structures require a decision, usually one of three: serialise the branch into a single cell, flatten it into dotted column names, or explode an array into multiple rows. Column names are the union of all keys — inferring from the first element silently drops fields unique to later ones.
[{"a":1},{"b":2}]a,b
1,
,2 (union of keys, gaps left empty)Measured on This Page
| Nested flattening | {"a":1,"b":{"c":2}} becomes two columns, a=1 and b.c=2, joined with a dot |
|---|---|
| Commas and quotes | Both "a,b" and he said "hi" come back wrapped in quotes with inner quotes doubled, and DictReader reads them identically |
| Newline preserved | An embedded \n stays inside the cell and reads back as two lines rather than splitting the file into two records |
| Big integer intact | 9007199254740993 travels as text and never becomes …992 |
| Round-trip equality | All four cases parse back through csv.DictReader with field values character-identical to the source |
CSV failures are all about escaping, and they look fine while being wrong: a comma splits a field into two columns, a newline turns one record into two, a stray quote truncates the value. Only three rules matter — wrap any field containing a comma, quote or newline in double quotes, double the inner quotes, and never trim leading or trailing spaces. All four measured cases round-trip exactly. Two practical notes: Excel may show UTF-8 Chinese as garbage unless a BOM is present (this output has none, which suits programs more than people), and flattened column names join with a dot (b.c), so source keys that already contain dots will collide and need another separator.
How to Use
- Open "JSON to CSV"
- Paste a JSON array of objects
- Pick a delimiter and toggle header or flattening
- Check row and column counts plus quoting
- Click "Download" for a .csv, or copy the text
Use Cases
- Export to Excel — Convert API JSON to CSV and open it in Excel or Sheets for tabular analysis.
- Database import — Convert JSON to CSV for bulk loading via LOAD DATA and similar commands.
- Generate reports — Convert JSON stats results to CSV for non-technical colleagues to review.
- Clean data — Sort, filter, and dedupe the converted CSV in spreadsheet software.
- Cross-tool exchange — Turn JSON into CSV, a format nearly every data tool supports.
- Machine learning — Convert a JSON dataset to CSV for training models with tools that expect tabular input.
- Pivot analysis — Flatten nested JSON objects into CSV columns to run pivot tables in spreadsheet software.
FAQ
Must JSON be an array?
Yes. CSV is a 2D table, so JSON should be an array of objects (one object per row). A single object is treated as a one-row table.
Will commas in values break it?
No. Values with commas, newlines, or quotes are automatically wrapped in double quotes and escaped per RFC 4180.
What if objects have different fields?
The tool collects every key seen across all objects as the header; cells missing in a given object are left blank.
Can I choose the delimiter?
Comma by default. For TSV (tab) or semicolons, replace in an editor afterward or use the List Converter tool.
How are nested objects flattened?
Nested fields become dotted column names (e.g. user.name) rather than raw object text, keeping columns predictable for spreadsheet manipulation.
What should I watch for when opening in Excel?
If Chinese text appears garbled, the file likely lacks a BOM; re-save as UTF-8 with BOM (or transcode) so Excel detects the encoding correctly.
Can I convert it back to JSON exactly?
Usually not. CSV stores every value as a string, so going back loses typed information such as numbers, booleans, and null. Flattened dotted columns like user.name cannot be reliably restored to the original nesting, and the array structure is not preserved either. If round-tripping matters, keep the original JSON as a separate metadata source and normalize dates and empty values before exporting; otherwise treat CSV as a one-way export for display or import rather than a reversible format.
How are nested objects handled in the CSV output?
CSV is flat, so nested fields are flattened into dotted paths (user.address.city) and arrays expand to multi-values or JSON strings. The path separator determines column names — adjust it in the options if the downstream system expects a specific format.