Skip to main content

nano-csv2json

PyPI License Size CI

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.


✨ Features

  • ✅ 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

🚀 Usage

# Local (from repo)
python app_min.py data.csv
python app_min.py --no-header data_nohdr.csv

After installing:

# CLI
pip install nano-csv2json
nano-csv2json data.csv > out.jsonl
type data.csv | nano-csv2json         # Windows
cat data.csv | nano-csv2json          # Linux/macOS

Output is JSON Lines (newline-separated JSON objects).


🤓 Why so small?

  • 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 via csv.reader.
  • Single tiny file + tiny CLI: perfect for scripts, containers, CI.

🎉 Fun Ideas

  • 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.jsonl

Tip: Need a single JSON array? Collect lines with jq: nano-csv2json data.csv | jq -s '.' > array.json


📜 License

MIT © 2025

Release files for nano-csv2json 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nano-csv2json 0.1.0
File Size Uploaded
nano_csv2json-0.1.0.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nano-csv2json 0.1.0
File Interpreter ABI Platform
nano_csv2json-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / nano_csv2json-0.1.0.tar.gz

Download URL nano_csv2json-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
157757b12ff0752e2c1a0c4d9fc54f9ad759495fbfc8addd974b28e85bad6b8f
BLAKE2b-256 checksum
How to use checksums
c6d0b39d11ae5609573dcc59b3873bd6bc930cc6393a2d1389adbe953eddc8ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / nano_csv2json-0.1.0-py3-none-any.whl

Download URL nano_csv2json-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3136f4fc061ad1487d283d52b0a9eeecfe23e9286059759e6eb29a6f5f332d87
BLAKE2b-256 checksum
How to use checksums
4a128c7d71630005636058728f6112681ba75e52ee23d73c5c18937b146d5387
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page