JSON to CSV

Turn JSON records into a spreadsheet-ready CSV table.

Reverse
Input
JSON input
Output
Result
Options

Turns { "user": { "name": x } } into a user.name column.

Further reading

  • How to convert JSON to CSVConvert JSON to CSV correctly: flattening nested objects, handling arrays and missing keys, choosing a delimiter, and the cases where CSV cannot represent the data.

About this tool


CSV is a flat grid; JSON can be a tree. This converter flattens nested objects into dotted columns by default and ordinarily pads missing fields with empty cells. Flattening can overwrite colliding paths and drop empty nested objects. Warnings cover some transformations, not every assumption or loss, so compare the result with the source before relying on it.

The usual goal is getting JSON into a spreadsheet, a BI tool, or a bulk-import form. Those all want one header row and a consistent column count, which is exactly what this produces.

How to use it

  1. Paste or upload JSONAn array of objects works best: [{"id":1},{"id":2}].
  2. Choose flatteningLeave flattening on to expand nested objects into dotted columns, or turn it off to keep them as JSON text in a single cell.
  3. ConvertPress Convert to CSV, or use Ctrl+Enter.
  4. Read the warningsWarnings cover differing fields, dotted columns and JSON-text cells, but do not report every loss. Check for colliding paths, dropped empty objects and numeric rounding yourself.
  5. Download the CSVSave it as a .csv file and open it in your spreadsheet.

Worked examples


Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.

Records with a nested object

Input

[{"id":1,"user":{"name":"Ada"},"active":true},{"id":2,"user":{"name":"Bob"},"active":false}]

Output

id,user.name,active
1,Ada,true
2,Bob,false

The nested user object becomes a user.name column.

Records with different fields, and a value containing a comma

Input

[{"a":1,"note":"x, y"},{"a":2,"b":3}]

Output

a,note,b
1,"x, y",
2,,3

Every row has three fields. The comma-containing value is quoted; missing values are empty.

What to watch for


The details that decide whether a conversion is correct, and where information can be lost without any error being raised.

Columns come from the union of all keys
After optional flattening, the header is built from the union of record keys in JavaScript enumeration order, adding each new key as it is encountered. For ordinary keys, a missing field gets an empty cell, and each output row matches the header width. Special JavaScript property names need care: a missing constructor can expose an inherited value, while __proto__ can disappear during flattening or yield an unexpected cell. Rename such keys before conversion. Padding does not protect data lost earlier through parsing or flattening. If no fields remain, conversion fails.
Nested objects become dotted columns
An object like {"user":{"name":"Ada","city":"London"}} produces user.name and user.city columns. This is not lossless: a literal user.name key can collide with the nested path, the later visited value wins, and empty nested objects produce no column. Turning flattening off writes nested objects as JSON text in cells, preserving their parsed structure rather than their original text or any precision already lost during parsing.
Arrays cannot be flattened, so they become JSON text
There is no sensible column layout for a variable-length list, so an array value is written as JSON inside its cell: ["admin","dev"] stays literally that. If you need one row per array element, restructure the JSON before converting, CSV has no way to express a repeated group.
Quoting follows RFC 4180
A value is wrapped in double quotes when it contains the delimiter, a double quote, or a line break. Embedded quotes are doubled, so he said "hi" becomes "he said ""hi""". This is what Excel, Google Sheets and every conforming parser expect.
Type information is lost
CSV carries no JSON type metadata. The number 42 and the string "42" produce the same text; true becomes plain characters, and null, an empty string and an ordinary missing field all become empty cells. On return, CSV to JSON keeps dotted headers as flat keys and JSON-text cells as strings. Optional type inference does not reconstruct the original tree or reliably restore its types.

Limitations


  • Arrays become JSON-text cells. Flattening can overwrite colliding dotted paths and drop empty nested objects, without dedicated loss warnings.
  • CSV has no JSON type metadata. Reverse conversion keeps dotted keys flat and JSON-text cells as strings; it does not rebuild nesting.
  • null, empty strings and ordinary missing fields become indistinguishable. Special JavaScript property names can produce unexpected or missing cells. JSON.parse keeps the last duplicate key, may round numbers, and can produce Infinity from overflow before CSV is written.
  • Processing happens in your browser, so very large inputs are bounded by available memory. Files above roughly 10 MB are handled but will feel slower, and multi-hundred-megabyte files are better suited to a command-line tool.

Questions


What JSON shape does this need?
A non-empty array of objects is ideal. An object whose sole property is an array, such as {"data":[...]}, is unwrapped into rows. Add any other property and the object becomes one record instead, with the array written as JSON text in a cell. A bare array of numbers becomes a single "value" column. An empty input array, or an empty array unwrapped as rows, is rejected. Conversion also fails when no record contributes an output field.
Why is my array shown as JSON inside a cell?
Array values are serialised as JSON text inside a cell, with CSV quoting added when needed. This retains their parsed JSON representation, not their original spelling or precision already lost during parsing. CSV to JSON leaves that cell as a string rather than parsing it back into an array. If you need one row per element, reshape the JSON first.
Can I convert the CSV back to the original JSON?
Not in general. CSV to JSON returns flat records: user.name stays a literal key, and cells containing JSON arrays or objects stay strings. Type inference is optional and cannot recover all original types; empty cells become empty strings by default or null if selected. Lost fields, overwritten paths and rounded numbers cannot be recovered.
Why does Excel mangle my long numbers or dates?
Excel can reformat imported values, including long IDs and date-like text such as 1-2. But this converter first uses JSON.parse and JavaScript IEEE 754 numbers, so large integers and precise decimals may already be rounded before CSV is produced. Overflowing numbers become Infinity text in scalar cells or null inside JSON-text cells. Quote exact identifiers in the source JSON, then import their columns as Text in Excel. Import settings cannot restore digits already lost.