@mini-tool-lab/json2csv
v1.0.1
Published
💼 **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
Readme
💼 Pro version available
Adds support for custom CSV delimiters and extended options.
👉 https://minitoollab.gumroad.com/l/json2csvpro?_gl=11cio27s_gaMTE2NzE5NTc0MS4xNzY1ODMzOTgy_ga_6LJN6D94N6*czE3NjYxNzMyNTgkbzQkZzAkdDE3NjYxNzMyNTgkajYwJGwwJGgw
json2csv
A predictable CLI to flatten JSON into CSV. Built for API responses, logs, and anything else that refuses to behave.
Why this exists
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.
Install
npm
npm install -g json2csvNote: If you publish under a different npm package name (recommended for uniqueness), update the install command accordingly.
Usage
From a file:
json2csv input.json > output.csvFrom stdin:
cat input.json | json2csv > output.csvFrom an API:
curl -s https://api.example.com/data | json2csv > data.csvFlattening rules
Nested objects become dot-notation columns
user.profile.nameArrays of primitives are joined with
|tags → "a|b|c"Arrays of objects become indexed columns
items[0].id,items[1].idEmpty or missing values are preserved as empty cells
Column order is stable and alphabetical
Example
Input
{
"id": 1,
"user": { "profile": { "name": "Tim" } },
"tags": ["x", "y"],
"items": [
{ "sku": "A1", "qty": 2 },
{ "sku": "B2", "qty": 1 }
]
}Output
id,items[0].qty,items[0].sku,items[1].qty,items[1].sku,tags,user.profile.name
1,2,A1,1,B2,x|y,TimDesign goals
- Predictable output
- Safe for scripts and CI
- No config files
- No external services
- No telemetry
License
MIT
