💼 **Pro version available** Adds support for custom CSV delimiters and extended options. 👉 https://minitoollab.gumroad.com/l/json2csvpro?_gl=1*1cio27s*_ga*MTE2NzE5NTc0MS4xNzY1ODMzOTgy*_ga_6LJN6D94N6*czE3NjYxNzMyNTgkbzQkZzAkdDE3NjYxNzMyNTgkajYwJGwwJG
npm install @mini-tool-lab/json2csv💼 Pro version available
Adds support for custom CSV delimiters and extended options.
👉 https://minitoollab.gumroad.com/l/json2csvpro?_gl=11cio27s_gaMTE2NzE5NTc0MS4xNzY1ODMzOTgy_ga_6LJN6D94N6*czE3NjYxNzMyNTgkbzQkZzAkdDE3NjYxNzMyNTgkajYwJGwwJGgw
A predictable CLI to flatten JSON into CSV. Built for API responses, logs, and anything else that refuses to behave.
If you’ve ever:
- Exported JSON from an API and needed it in Excel
- Shared data with someone who does not speak JSON
- Debugged deeply nested payloads
- Used a random online JSON-to-CSV site you didn’t trust
This tool is for you.
json2csv turns messy, nested JSON into a clean, scriptable CSV you can use anywhere.
bash
npm install -g json2csv
`
> Note: If you publish under a different npm package name (recommended for uniqueness),
> update the install command accordingly.Usage
From a file:
`bash
json2csv input.json > output.csv
`From stdin:
`bash
cat input.json | json2csv > output.csv
`From an API:
`bash
curl -s https://api.example.com/data | json2csv > data.csv
`Flattening rules
- Nested objects become dot-notation columns
user.profile.name- Arrays of primitives are joined with
|
tags → "a|b|c"- Arrays of objects become indexed columns
items[0].id, items[1].id- Empty or missing values are preserved as empty cells
- Column order is stable and alphabetical
Example
$3
`json
{
"id": 1,
"user": { "profile": { "name": "Tim" } },
"tags": ["x", "y"],
"items": [
{ "sku": "A1", "qty": 2 },
{ "sku": "B2", "qty": 1 }
]
}
`$3
`csv
id,items[0].qty,items[0].sku,items[1].qty,items[1].sku,tags,user.profile.name
1,2,A1,1,B2,x|y,Tim
``- Predictable output
- Safe for scripts and CI
- No config files
- No external services
- No telemetry
MIT