Serialize JSON without extra whitespace.
Section: Minify JSON
Minify with Python
bash
bash
python - <<'PY'
import json
from pathlib import Path
p = Path('data.json')
obj = json.loads(p.read_text())
print(json.dumps(obj, separators=(',', ':')))
PYExplanation
The `separators` option removes spaces after commas and colons.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Minify JSON