JSON Minifier
Compress JSON by removing all whitespace. Shows exact bytes saved.
What is JSON Minification?
JSON minification removes all unnecessary whitespace — spaces, tabs and newlines — from a JSON document without changing its data. The result is a single-line JSON string that takes fewer bytes to store and transmit.
Example
Before (79 bytes):
{
"user": {
"id": 1,
"name": "Ravi Mehta",
"city": "Surat"
}
}After minification (47 bytes — 40% smaller):
{"user":{"id":1,"name":"Ravi Mehta","city":"Surat"}}Both represent exactly the same data. Only whitespace is removed.
When to Minify JSON
- ▸Production API responses — Every extra space is wasted bandwidth multiplied across thousands of requests
- ▸Embedding in HTML — Minified JSON in script tags reduces page weight directly
- ▸Database storage — Storing in a TEXT column — fewer bytes means lower storage cost
- ▸Configuration deployment — Minify before deploying large JSON config files to production servers
Do not minify JSON files that developers edit by hand. Readability is worth the extra bytes for config files.
Minify JSON in Code
JavaScript:
// One line — parse then re-stringify without indent
const minified = JSON.stringify(JSON.parse(formatted));Python:
import json
minified = json.dumps(json.loads(formatted), separators=(",", ":"))Node.js (file to file):
const fs = require("fs");
const data = JSON.parse(fs.readFileSync("input.json", "utf8"));
fs.writeFileSync("output.min.json", JSON.stringify(data));Minify vs Compress
Minification and compression (gzip, brotli) are two different things. Minification removes whitespace at the text level. Compression works at the binary level and is applied by the web server. For maximum savings, use both — minify your JSON first, then let your server apply gzip. Minified JSON compresses better because it has less repetition.