json-csv-cli
v1.0.0
Published
Zero-dependency CLI to convert between JSON and CSV
Downloads
37
Readme
json-csv-cli
Zero-dependency CLI tool to convert between JSON and CSV — in both directions.
Install
npm install -g json-csv-cliOr run without installing:
npx json-csv-cli data.jsonUsage
json-csv-cli <input> [output] [options]Examples
# JSON → CSV (print to terminal)
json-csv-cli data.json
# JSON → CSV (save to file)
json-csv-cli data.json output.csv
# CSV → JSON (pretty-printed)
json-csv-cli data.csv output.json --pretty
# Custom delimiter (semicolon)
json-csv-cli data.csv --delimiter=;Options
| Flag | Description | Default |
|------|-------------|---------|
| --pretty | Pretty-print JSON output | off |
| --delimiter=X | CSV field delimiter | , |
| --help | Show help | — |
Features
- ✅ JSON array or single object → CSV
- ✅ CSV → JSON array with auto-cast (numbers, booleans)
- ✅ Nested JSON objects flattened to dot-notation (
user.name) - ✅ Quoted fields with commas, newlines, or quotes handled correctly
- ✅ Custom delimiter support (semicolon, tab, pipe, etc.)
- ✅ Zero dependencies — pure Node.js
Input/Output Examples
JSON → CSV
[
{ "name": "Alice", "age": 30, "city": "Paris" },
{ "name": "Bob", "age": 25, "city": "Berlin" }
]name,age,city
Alice,30,Paris
Bob,25,BerlinNested JSON → CSV (dot-notation)
[{ "user": { "name": "Alice", "role": "admin" } }]user.name,user.role
Alice,adminCSV → JSON
name,age,active
Alice,30,true
Bob,25,false[
{ "name": "Alice", "age": 30, "active": true },
{ "name": "Bob", "age": 25, "active": false }
]Running Tests
npm testLicense
MIT
