JSON Minifier
Strip whitespace from JSON to shrink payloads, with a live byte-size saving comparison.
JSON Minifier tool
What this tool does
Minifying JSON means removing every byte that only exists for human readers: the newlines between members, the indentation in front of them, and the space after each colon and comma. Nothing else changes. The parsed value that comes out is identical to the one that went in.
The tool shows what that is worth — original size, minified size, the percentage saved and, where your browser supports it, the gzipped size of the result — and can additionally emit the JSON as an escaped string literal or percent-encoded, which is what you need when the document has to survive a config file or a URL.
Common uses
- Packing a JSON value into an environment variable, a Kubernetes secret or a CI variable, where a multi-line value is awkward or forbidden.
- Shrinking a fixture that is committed to a repository and read by machines only.
- Putting a small JSON payload into a query string or a data attribute, where the escaped and URL-encoded forms matter more than the raw one.
- Trimming a response body before pasting it into a ticket or a chat message.
- Measuring the real cost of pretty-printing a payload your API returns on every request.
A short example
72 bytes of formatted JSON:
{
"id": 7,
"tags": [
"alpha",
"beta"
],
"active": true
} becomes 46 bytes — a 36% saving:
{"id":7,"tags":["alpha","beta"],"active":true} What minifying does and does not change
The output is produced by parsing the document and re-serialising it, which has two visible consequences beyond whitespace removal:
- Numbers are re-serialised.
1.0becomes1,1e3becomes1000and1.50becomes1.5. The values are equal; the text is not. If you are comparing checksums of the document rather than of the data, that difference matters. - Escapes are normalised. A string written as
"caf\u00e9"comes back as"café", because only",\and the control characters belowU+0020have to be escaped. Both spellings are correct JSON for the same string, but a byte-for-byte comparison will disagree.
Key order is never touched, so a minified document diffs cleanly against another minified document from the same source.
Worth knowing
Over HTTP, minifying is worth much less than it looks. Whitespace is the most compressible
thing in a document — long runs of identical spaces are exactly what DEFLATE encodes in a few
bits — so a payload that shrinks 30% when minified often shrinks only 2–5% more after gzip or
Brotli compression on top. If your API already sends
Content-Encoding: gzip, spend the effort on the number of fields you return
instead. Minifying still wins where compression is not in play: env vars, URLs, database
columns and log lines.
Frequently asked questions
Will minifying break a webhook signature or a JWT?
Yes. GitHub, Stripe and Shopify compute their HMAC over the exact request body, and a JWS signature covers the exact Base64url text of the payload, so re-serialising a document — even with identical data — yields a different digest and the check fails. Verify against the bytes you received, then minify a copy for storage. For tokens, use the JWT decoder rather than reshaping them.
How much JSON can I safely put in a URL?
Less than the minified size suggests. Percent-encoding turns each {, " and : into three characters, and the whole request line must fit the server’s buffer: nginx allows 8 KB by default through large_client_header_buffers, and Apache’s LimitRequestLine is 8190 bytes. Past roughly 2 KB of raw JSON, move the payload into a POST body.
Should I commit minified JSON to Git?
Usually not. Git compares line by line, so a single-line document reports every edit as a rewrite of the whole file and a merge conflict swallows the entire payload. Keep the readable copy in the repository and minify at build time. Where you are stuck with one, git diff --word-diff at least isolates the changed tokens, and re-formatting it makes review possible.