https://github.com/sulthonzh/csv2json
Convert CSV to JSON from the terminal. Zero deps.
https://github.com/sulthonzh/csv2json
cli convert csv csv2json json
Last synced: 1 day ago
JSON representation
Convert CSV to JSON from the terminal. Zero deps.
- Host: GitHub
- URL: https://github.com/sulthonzh/csv2json
- Owner: sulthonzh
- License: mit
- Created: 2026-06-10T06:05:26.000Z (16 days ago)
- Default Branch: main
- Last Pushed: 2026-06-15T09:45:48.000Z (11 days ago)
- Last Synced: 2026-06-15T11:51:59.837Z (11 days ago)
- Topics: cli, convert, csv, csv2json, json
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# csv2json
Convert CSV to JSON right in your terminal. Zero dependencies.
You've got a CSV file. You need JSON. That's it. No Excel, no Python, no online converter that's secretly harvesting your data.
## Install
```bash
npm install -g csv2json-cli
```
## Usage
```bash
# Basic — outputs JSON array
csv2json users.csv
# Pretty printed
csv2json users.csv --pretty
# Read from stdin
cat data.csv | csv2json -
# Output as JSON Lines (one object per line)
csv2json users.csv -o jsonl
# Table format (quick preview)
csv2json users.csv -o pretty
```
## Filtering & Selecting
```bash
# Pick specific columns
csv2json users.csv -s name,email
# Filter rows
csv2json users.csv -w "age>25"
csv2json users.csv -w "status=active"
csv2json users.csv -w "name~alice" # contains (case-insensitive)
# Combine them
csv2json users.csv -s name,age -w "age>30"
```
## Options
| Flag | Short | Description |
|------|-------|-------------|
| `--delimiter ` | `-d` | CSV delimiter (auto-detected by default) |
| `--output ` | `-o` | Output format: `json` (default), `jsonl`, `pretty` |
| `--pretty` | `-p` | Pretty-print JSON output |
| `--select ` | `-s` | Select specific columns (comma-separated) |
| `--where ` | `-w` | Filter: `field=value`, `field>5`, `field~text` |
| `--no-header` | | First row is data, not headers |
| `--help` | `-h` | Show help |
### Where operators
| Op | Meaning |
|----|---------|
| `=` | Equals |
| `!=` | Not equals |
| `>` | Greater than |
| `<` | Less than |
| `~` | Contains (case-insensitive) |
## Auto-Detection
Detects delimiter automatically — comma, tab, semicolon, pipe. Works with:
- Standard CSV
- TSV (tab-separated)
- Semicolon-separated (common in European locales)
- Pipe-delimited
## Type Coercion
Values are automatically converted:
- Numbers → `42`, `3.14`
- Booleans → `true`, `false`
- Null → `null`
- Everything else stays a string
## Why
Because every other CSV-to-JSON tool either needs Python, opens a browser, or has 47 dependencies. This one does one thing and does it with zero deps.
## License
MIT