Tiny CSV β JSON Lines converter β ~1 KB, zero deps. Single-file, CLI included. Auto-sniffs delimiter; headers optional. Perfect for code-golf, minimal containers, or just for fun.
- β CSV β JSONL (one JSON per line)
- β
Auto-detect delimiter (
,,;,\t, β¦) - β
Uses header row if present;
--no-headerβ keys:c1,c2,... - β Zero dependencies, single tiny file
# Local (from repo)
python app_min.py data.csv
python app_min.py --no-header data_nohdr.csvAfter installing:
# CLI
pip install nano-csv2json
nano-csv2json data.csv > out.jsonl
type data.csv | nano-csv2json # Windows
cat data.csv | nano-csv2json # Linux/macOSOutput is JSON Lines (newline-separated JSON objects).
- Uses only the stdlib:
csv,json,ioβ no pandas. - Auto-detects delimiter with
csv.Sniffer()(comma/semicolon/tabβ¦). - Streams to JSON Lines (one JSON per line) β no in-memory data frames.
- Header row β
csv.DictReader;--no-headerβc1,c2,...keys viacsv.reader. - Single tiny file + tiny CLI: perfect for scripts, containers, CI.
- Pretty-print JSONL
nano-csv2json data.csv | python -m json.tool- Filter with jq
nano-csv2json data.csv | jq -r 'select(.status=="ok")'- STDIN piping
curl -s https://example.com/data.csv | nano-csv2json > out.jsonl
# Windows
Invoke-WebRequest https://example.com/data.csv -UseBasicParsing | nano-csv2json > out.jsonl- Semicolon/TSV auto-sniff
nano-csv2json data_semicolon.csv > out.jsonl
nano-csv2json data.tsv > out.jsonl- No header β synthetic keys
nano-csv2json --no-header raw.csv | head -1
# {"c1":"val1","c2":"val2",...}- Compress on the fly
nano-csv2json data.csv | gzip > out.jsonl.gz- First N records
nano-csv2json data.csv | head -100 > sample.jsonlTip: Need a single JSON array? Collect lines with jq: nano-csv2json data.csv | jq -s '.' > array.json
MIT Β© 2025