Yueseryueser.com

← All guides

JSON to CSV Guide: Flat Data Only

JSON nests; CSV does not. Before converting, ask whether the data is really one row per record with the same fields. If not, something will be lost.

Open the tool:JSON to CSV

Handing API data to people who do not code

Operations wants an order list, finance needs to check a batch of records, and a monitoring export has to become a pivot table. All of these want CSV. Sent as JSON, the recipient sees a wall of braces; converting is the cheapest bridge.

The shape that works is narrow: an array whose elements are objects with broadly the same keys. The more the keys differ, the more holes the table has — a sign to revisit the data model instead of forcing the export.

Headers, missing fields, and escaping

Headers come from the first object's keys, in that order. Keys that appear only in later objects are dropped entirely; keys that are missing produce empty cells. Make sure the first object covers every field, or compute the union first.

When a value contains a comma, a double quote, or a newline, the whole field is wrapped in quotes and inner quotes are doubled. Skipping this is fatal: one comma shifts the rest of the row. Header names containing commas are not escaped, so rename them beforehand.

Boundary: nesting and Excel's habits

A nested object becomes the string [object Object], and an array is joined into one comma-separated string. CSV has nowhere to put the hierarchy. If structure matters, split into related tables with IDs, or deliver JSON.

Excel's double-click import guesses the encoding, so UTF-8 Chinese may be garbled, long numbers turn into scientific notation, and zero-padded IDs lose their leading zeros. Use the text import wizard and pick UTF-8, or emit a file with a byte-order mark.

FAQ

Why do I see [object Object]?

That field is an object or a nested structure, and a CSV cell can only hold text. Flatten it first, for example to a dotted key, then export.

Why is Chinese garbled in Excel?

Double-clicking makes Excel guess the encoding, and it often guesses wrong for UTF-8. Import through the text wizard with UTF-8 selected, or generate the file with a byte-order mark.

Can I control the column order?

The tool follows the first object's key order. To fix an order, put a correctly ordered object containing every field at the start of the array, or reorder columns in the spreadsheet afterwards.

Related tool:JSON to CSV