Remove all whitespace from JSON to reduce file size for production. Free online JSON compressor — instant results, no signup.
Minify JSON Now →Prettified (428 bytes):
{
"user": {
"id": 101,
"name": "Alice Johnson",
"email": "alice@example.com",
"roles": [
"admin",
"editor"
],
"active": true
}
}
Minified (121 bytes — 72% smaller):
{"user":{"id":101,"name":"Alice Johnson","email":"alice@example.com","roles":["admin","editor"],"active":true}}
| Use Case | Benefit |
|---|---|
| API responses | Reduces bandwidth, faster response times |
| localStorage / cookies | More data fits within size limits (5MB for localStorage) |
| Embedded in HTML/JS | Smaller page size, faster initial load |
| Mobile networks | 30-50% size reduction on slow connections |
| CDN / edge caching | Lower storage costs at scale |
// Minify a pretty-printed JSON string
const minified = JSON.stringify(JSON.parse(prettyJson));
// Minify a JavaScript object
const minified = JSON.stringify(myObject); // no indent arg = minified
// Minify while removing specific keys (e.g. debug fields)
const minified = JSON.stringify(myObject, (key, value) => {
if (key === '__debug' || key === '_internal') return undefined;
return value;
});
# Using Python (no install needed)
python3 -c "import json,sys; print(json.dumps(json.load(sys.stdin)))" < data.json
# Using jq
cat data.json | jq -c .
# Using Node.js
node -e "process.stdout.write(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'))))" < data.json
import json
with open('data.json') as f:
data = json.load(f)
# Minified (no separators = most compact)
minified = json.dumps(data, separators=(',', ':'))
# Save to file
with open('data.min.json', 'w') as f:
f.write(minified)
Also useful: JSON Beautifier | JSON Formatter | JSON Validator | JSON to CSV | JSON Repair