Skip to content

Convert JSON to CSV

Turn API responses, exports and JSON Lines into a CSV that opens cleanly in Excel — the records found for you, nested fields flattened into readable columns, and large IDs kept digit for digit.

  • Never stored
  • No queue, no waiting
  • No signup, no watermark

How it works

1

Add JSON

Drop a .json or .jsonl file, or paste the JSON straight into the box.

2

Pick the records

The list of records is found automatically, even deep inside data.items. Choose how arrays are written and check the preview.

3

Download

A CSV with the delimiter and encoding you need, ready for Excel, Google Sheets or a database.

Flattening a tree into a grid

JSON is a tree and CSV is a rectangle, and the whole conversion is the question of how one becomes the other. The clean case is an array of objects that all share the same keys — each object is a row, each key a column, and nothing is lost. That is what most API responses and exports look like, which is why this usually just works. Everything awkward comes from documents that are not that shape.

Nested objects are flattened by joining their keys, so an address object inside a customer becomes columns like address.city and address.postcode — a convention every spreadsheet handles and no standard defines. Keys that appear in some objects and not others become columns that are empty in the rows that lacked them, which is the right answer: the alternative is dropping data that only some records carry.

Nested arrays are where a grid genuinely cannot follow. One record with three order lines inside it is one row containing a list, not three rows — turning it into three would duplicate every other field and quietly change what the data means. So one array of objects is expanded into rows and any others are written into their cell as text. If what you need is the order lines rather than the orders, point the conversion at that array instead; a tree with two lists side by side has no single correct rectangle, and picking one is a decision only you can make.

Two details bite on the way out. Values containing a comma, a quote mark or a line break are quoted so they survive — which is correct CSV and looks odd if you inspect the raw file. And a long numeric identifier is a hazard once the CSV reaches a spreadsheet: Excel will read it as a number, round it beyond fifteen digits and strip any leading zero, which is a problem introduced by the spreadsheet rather than by the conversion.

When you want something else

jq is the right tool when the shape needs deciding rather than guessing: jq -r '.orders[] | [.id, .customer.name, .total] | @csv' picks exactly the fields you want from exactly the level you want them, which is the control an automatic flattener cannot offer. It also streams, so file size stops being a consideration.

For nested data generally, Miller — mlr --ijson --ocsv flatten — and Python's pandas.json_normalize give you explicit control over how deep to flatten and what to do with lists. And if the JSON is genuinely hierarchical rather than tabular, converting it to CSV may be the wrong idea altogether — a database or a line-delimited JSON file keeps the structure that a grid is about to discard.

Frequently asked questions

How does nested JSON become columns?

Each nested field becomes one column named by its path: {"address": {"city": "Oslo"}} gives a column address.city. Columns appear in the order they first occur in your data, not alphabetically, and records missing a field simply leave that cell empty.

What happens to arrays?

You choose: join the values into one cell ("red; green"), spread them across numbered columns (tags.0, tags.1), keep them as JSON text, or — for an array of objects such as order lines — write one row per item with the parent fields repeated.

Are large numbers kept exactly?

Yes. IDs beyond what JavaScript can represent — Twitter, Discord and 64-bit database IDs — are copied digit for digit, where most converters silently round 1234567890123456789 to 1234567890123456800.

Is JSON Lines (NDJSON) supported?

Yes. A file with one JSON object per line is recognised automatically, and every line becomes a row.

What if my JSON has an error?

You get the exact line and column with the offending text highlighted, and a plain explanation — for example a trailing comma, or single quotes copied from JavaScript code.

Is my data stored anywhere?

No. The JSON is read and the CSV written here; nothing is sent anywhere and nothing is stored.

Good to know: Only one array of objects can be expanded into rows at a time; other arrays are written into their cell. Very large files are limited by your browser's memory.

Put this tool on your website

Free for any blog, class page or help article. Paste one snippet and your visitors can use it right on your page.