JSON to CSV from an API response - flatten nested fields without breaking the table
A practical workflow for turning API JSON into spreadsheet-ready CSV, choosing delimiters and understanding nested-field flattening in the browser.
You have an API response from an issue, a webhook payload or mock data for a test. The JSON is readable, but someone needs a table: open it in a spreadsheet, filter rows, scan email, status, date and two nested fields. The easy failure is a CSV that downloads but is hard to use: nested objects stay hidden in JSON strings, commas move columns around, and arrays become guesswork.
Use this order:
| Step | Check |
|---|---|
| 1 | The JSON root should be an object or array, not a standalone string, number, boolean or null |
| 2 | Run it through JSON formatter first if the syntax is suspicious |
| 3 | In JSON to CSV, choose the delimiter for the target spreadsheet |
| 4 | Inspect flattened column names: profile.name, items[0].sku, tags[1] |
| 5 | For large files or repeatable ETL, move the transform to jq, Python or a pipeline |
Which JSON shape works well as CSV
CSV is a flat table: one header row and data rows. JSON is a tree. Arrays of objects convert best:
[
{
"id": 42,
"email": "ada@example.com",
"profile": { "role": "admin", "team": "platform" }
},
{
"id": 43,
"email": "linus@example.com",
"profile": { "role": "dev", "team": "kernel" }
}
]
That JSON becomes multiple rows. A single object is supported too; it becomes one row. A root value like "ok", 123, true or null does not become a useful table without inventing a column. Devdeck shows an error instead of guessing a shape for you.
If the API returns a wrapper such as { "data": [...], "meta": {...} }, inspect the result carefully. The converter will flatten the whole envelope as one row: you get columns such as data[0].id, data[1].id and meta.total, not one row per data item. For a clean table, you often want the array inside data, not the full response envelope.
What nested-field flattening means
Nested objects and arrays are not dropped. Devdeck expands them into path columns:
| JSON field | CSV column |
|---|---|
{ "profile": { "name": "Ada" } } | profile.name |
{ "tags": ["admin", "beta"] } | tags[0], tags[1] |
{ "items": [{ "sku": "A1" }] } | items[0].sku |
{ "extra": {} } | extra with value {} |
{ "flags": [] } | flags with value [] |
That is useful for API responses where you need specific nested fields visible in a spreadsheet. It is not full data modeling. If one order has 10 items and another has 2, CSV gets columns like items[0]...items[9], with blanks in many rows. For a report with one row per item, write a small transform instead of expecting a generic converter to know your business model.
Delimiter: comma, semicolon, tab or pipe
CSV does not have to mean comma-only. Devdeck lets you choose comma, semicolon, tab or pipe. If the file is going into Excel with a European locale, semicolon often opens more predictably. For pasting into Google Sheets or moving data between temporary tables, tab can be cleaner because it conflicts less with ordinary text.
Cells are escaped with CSV rules: when a value contains a quote, line break or the selected delimiter, the cell is wrapped in double quotes and quotes inside the value are doubled. So "an address had a comma and the columns shifted" is a CSV-building problem, not something you should fix by manually replacing characters.
One caveat for user-generated data: Excel and Google Sheets may interpret values starting with =, +, - or @ as formulas. Devdeck preserves source values; it does not sanitize cells for a specific spreadsheet. If the CSV will leave your machine and contains untrusted text, escape those fields in a script or pipeline before publishing it.
Where the browser tool stops
JSON to CSV runs locally in the browser: JSON.parse, flattening and CSV generation happen in the tab. That fits an issue payload, small API response, webhook body, test data or manual ETL draft.
Local processing removes upload to the tool server, but it does not remove clipboard, browser-extension or shared-machine risks. For that boundary, see local developer tools in the browser.
For a 50 MB JSON file, production export or scheduled integration, do not make a tab carry the job. Use a CLI or code near the contract: jq, Python, a Node script, dbt or an ETL pipeline. That is where you can decide which arrays become rows, which fields are renamed, how dates are normalized and how missing values are handled.
If you later need to go back in the other direction, use CSV to JSON, but do not treat it as a perfect round trip. CSV loses types: numbers, booleans and dates become text, while null becomes an empty cell unless a separate schema restores them.
Before sending the table onward, check four things: you selected the right array from the response, nested fields landed in understandable columns, the target spreadsheet opened the CSV with the same delimiter, and untrusted text will not turn into spreadsheet formulas.
Questions
Can any JSON be converted to CSV?
No. The JSON needs a table-like shape: a root object or array. Root strings, numbers, booleans and null are rejected because they do not provide column names.
What happens to nested objects and arrays?
Devdeck flattens nested values into path columns such as profile.name, items[0].sku and tags[1]. Empty objects and arrays are preserved as {} and [].
Is JSON uploaded to a server during conversion?
No. JSON parsing, field flattening and CSV generation run in your browser. For large files, use jq or a project-local script instead of freezing a tab.