Jsonpretty
Format, validate, query, flatten, and analyze JSON data. Use when asked to pretty-print JSON, validate JSON syntax, query nested JSON with dot-notation, flat...
Latest: v1.0.0
- Initial release of jsonpretty, a pure Python tool for JSON formatting and analysis.
- Supports pretty-printing, validation with error messages, dot-notation querying (including array indices), and flattening of nested JSON.
- Provides JSON structure statistics: key count, maximum depth, data type summary, and byte size.
- Includes compact (minify) and key-sorting output modes.
- Works with files or stdin; zero external dependencies required.
Full description
Format, validate, query, flatten, and analyze JSON data. Use when asked to pretty-print JSON, validate JSON syntax, query nested JSON with dot-notation, flatten nested structures, get JSON statistics, or compact JSON output. Reads from files or stdin pipe. Zero dependencies — pure Python.
jsonpretty 📋
JSON swiss army knife — format, validate, query, flatten, stats.
Commands
# Pretty-print (from file or stdin)
python3 scripts/jsonpretty.py data.json
echo '{"a":1}' | python3 scripts/jsonpretty.py
# Validate JSON
python3 scripts/jsonpretty.py --validate data.json
# Query with dot-notation
echo '{"user":{"name":"Rogue"}}' | python3 scripts/jsonpretty.py -q "user.name"
# Flatten nested JSON
cat data.json | python3 scripts/jsonpretty.py --flat
# Structure stats (key count, depth, types, size)
python3 scripts/jsonpretty.py --stats data.json
# Compact output (minify)
python3 scripts/jsonpretty.py --compact data.json
# Sort keys
python3 scripts/jsonpretty.py --sort data.json
Features
- Pretty-print with 2-space indent (default)
- JSON validation with error messages
- Dot-notation querying (supports array indices:
key[0].sub) - Flatten nested objects to
key.subkey = valuepairs - Structure statistics: key count, nesting depth, type distribution, byte size
- Compact/minify mode
- Sorted key output
- Reads from file or stdin
