json-csv-convert-v2
v2.0.3
Published
Convert CSV and JSON files with interactive options to select, rename, and filter columns, as well as deduplicate records during conversion.
Readme
Convert V2
Convert V2 (npm package json-csv-convert-v2) is a fast, interactive CLI for converting between CSV and JSON. It adds zero-configuration interactivity for:
- Selecting columns/properties to keep or delete
- Remapping column/property names
- Deduplicating records by chosen keys
- Previewing a sample of output
- Output in JSON or CSV as desired
📦 Installation
npm install -g json-csv-convert-v2
# or for local/dev:
npm linkCLI Usage
# Run interactive converter:
json-csv-convert-v2 <inputFile> <outputFileOrDir>
# Example:
json-csv-convert-v2 users.csv ./outInteractive Workflow
- Select Output Format
Choose
JSONorCSV - Choose Columns Multi-select which headers to keep or delete
- Remap Columns
Edit or rename selected columns as
oldName → newName - Deduplicate Records Optionally pick one or more columns as dedupe keys
- Confirm & Run Review summary and press Enter to execute
Non-Interactive Flags
You can bypass prompts with named options:
| Flag | Shorthand | Description |
| ----------------- | --------- | ----------------------------------------------- |
| --format <fmt> | -f | Output format: json or csv |
| --keep <cols> | -k | Comma-separated list of columns to keep |
| --delete <cols> | -d | Comma-separated list of columns to delete |
| --remap <map> | -r | Comma-separated old:new pairs |
| --dedupe [keys] | | Dedupe by columns (comma-separated) |
| --sample <N> | -s | Preview N records before processing (default 5) |
| --help | -h | Show help text |
| --version | -v | Show version |
Example (one-liner):
json-csv-convert-v2 data.csv data.json \
--format json \
--keep id,name,email \
--remap email:contactEmail \
--dedupe idOutput
- JSON: pretty-printed array of objects
- CSV: headers from final columns; values joined by commas
- Creates target dir if needed
Exit Codes
| Code | Meaning | | ---- | -------------------------- | | 0 | Success | | 1 | Invalid arguments or flags | | 2 | File read/write errors | | 3 | Parse or transform errors |
License
MIT
