@asdsadw12312dwd2112xz/csv-to-json-cli
v1.0.0
Published
Convert CSV files to JSON and vice versa
Maintainers
Readme
csv-to-json-cli
Convert CSV files to JSON and vice versa. Zero-dependency CSV parsing — fully RFC 4180 compliant.
Install
npm install -g csv-to-json-cliUsage
CSV → JSON
csv2json csv2json data.csv
csv2json csv2json data.csv -o output.json --pretty
csv2json csv2json data.csv --delimiter ";" --fields "name,email"
cat data.csv | csv2json csv2json --pipeJSON → CSV
csv2json json2csv data.json
csv2json json2csv data.json -o output.csv
csv2json json2csv data.json --flat --delimiter "\t"
cat data.json | csv2json json2csv --pipeOptions
| Option | Description |
|---|---|
| -o, --output <file> | Write to file instead of stdout |
| -d, --delimiter <char> | Field delimiter (default: ,) |
| --no-header | CSV has no header row (fields named field1, field2, …) |
| --pretty | Pretty-print JSON with indentation |
| --flat | Flatten nested JSON objects for CSV output |
| --fields <list> | Include only specified fields (comma-separated) |
| --pipe | Read input from stdin |
Features
- Manual CSV parser — handles quoted fields, commas inside quotes, newlines in fields, escaped quotes
- Flatten nested JSON objects with dot notation
- Pick specific fields to include in output
- Stdin/stdout piping for shell pipelines
- Row and field count summary on stderr
License
MIT
