Skip to main content

Tiny CSV → JSON Lines converter in ~1KB (zero deps)

Project description

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, iono 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-headerc1,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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_csv2json-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_csv2json-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file nano_csv2json-0.1.0.tar.gz.

File metadata

  • Download URL: nano_csv2json-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_csv2json-0.1.0.tar.gz
Algorithm Hash digest
SHA256 157757b12ff0752e2c1a0c4d9fc54f9ad759495fbfc8addd974b28e85bad6b8f
MD5 ddae2551ef3252fe77f70bd0ee949d95
BLAKE2b-256 c6d0b39d11ae5609573dcc59b3873bd6bc930cc6393a2d1389adbe953eddc8ec

See more details on using hashes here.

File details

Details for the file nano_csv2json-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nano_csv2json-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nano_csv2json-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3136f4fc061ad1487d283d52b0a9eeecfe23e9286059759e6eb29a6f5f332d87
MD5 5916ab239fbcc73aebbe06ed469b0c93
BLAKE2b-256 4a128c7d71630005636058728f6112681ba75e52ee23d73c5c18937b146d5387

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page