Remove all whitespace from JSON to reduce file size for production. Free online JSON compressor — instant results, no signup.
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)
Free, instant — your data never leaves your browser.
Minifying JSON removes all unnecessary whitespace. This reduces payload size for APIs, speeds up network transfers, and shrinks configuration files. Every byte matters in high-traffic systems.
| File Type | Pretty Size | Minified Size | Savings |
|---|---|---|---|
| Small config (10 keys) | 320 bytes | 180 bytes | 44% |
| API response (50 fields) | 2.1 KB | 1.1 KB | 48% |
| Data array (1000 records) | 145 KB | 78 KB | 46% |
| Large schema (200+ rules) | 18 KB | 9.5 KB | 47% |
// JavaScript
const minified = JSON.stringify(obj);
// No indent argument = compact output
// Python
import json
minified = json.dumps(data, separators=(",", ":"))
// PHP
$minified = json_encode($data); // default is compact
// CLI
jq -c . input.json > minified.json
// Node.js file minifier
const fs = require("fs");
const data = JSON.parse(fs.readFileSync("big.json"));
fs.writeFileSync("min.json", JSON.stringify(data));
Minification removes all whitespace that is not part of a string value. The data is identical — only presentation characters are stripped. Here is a concrete example showing the size savings.
// Before (pretty printed): 187 bytes
{
"user": {
"id": 1,
"name": "Alice Smith",
"email": "alice@example.com",
"active": true,
"roles": [
"admin",
"editor"
]
}
}
// After (minified): 88 bytes — 53% smaller!
{"user":{"id":1,"name":"Alice Smith","email":"alice@example.com","active":true,"roles":["admin","editor"]}}
The right format depends on the audience — machines benefit from minified JSON, while humans need pretty-printed JSON. Use the right format for the right context.
| Context | Format | Reason |
|---|---|---|
| Production API response | Minified | Reduce bandwidth and parse time |
| Development API response | Pretty printed | Easier to read and debug |
| Config files in source control | Pretty printed | Human readable, diff-friendly |
| Embedded JSON in HTML/JS | Minified | Reduce page weight |
| JSON in database columns | Minified | Reduce storage size |
| Log entries | Minified | Compact single-line entries |
| Documentation examples | Pretty printed | Must be human-readable |
| API request payload | Minified | Reduce request size |
Also useful: JSON Beautifier | JSON Formatter | JSON Validator | JSON to CSV | JSON Repair