JSON Minifier
100% LocalMinify JSON by removing whitespace and show byte-size reduction stats.
Original Size
264 B
Minified Size
196 B
Reduction
26%
Paste JSON to strip whitespace and comments. The minified output preserves valid structure.
Learn More
Configuration Mastery: Taming the YAML vs. JSON vs. TOML War
We Benchmarked 6 JavaScript JSON Parsing Approaches: What Actually Wins in Practice
A realistic comparison of JSON.parse, streaming parsers, bigint-safe parsers, and WASM-based JSON libraries for normalized performance and memory trade-offs.
JSON Schema Validation: Stop Trusting API Responses Blindly
What is JSON Minifier?
Frequently Asked Questions
Technical Deep Dive
JSON Minifier
Paste formatted JSON and instantly get a minified single-line version. Displays original size, minified size, and percentage reduction with a visual progress bar. Validates JSON with helpful error messages and lets you download the output as a .json file.
Reliable Formatting
Idempotent, spec-compliant output, run it twice, get the same result.
Configurable Style
Indentation, quote style, and edge-case handling tunable to your team's conventions.
Big Inputs, Fast
Handles megabytes of code without freezing the tab, heavy lifting runs in workers.
Why and When to Minify JSON
Pretty-printed JSON is for humans; minified JSON is for machines. The same data structure that takes 2 KB pretty-printed often compresses to 1.3 KB minified, a 35% byte reduction with no information loss. Across millions of API responses per day, that adds up to meaningful savings in bandwidth costs, CDN egress, and end-user latency, especially on mobile networks.
What Minification Actually Removes
JSON's grammar treats whitespace as insignificant outside of strings. The minifier removes:
- Spaces between tokens (
{ "key": "value" }→{"key":"value"}) - Newlines and indentation
- Tabs
It does not remove:
- Whitespace inside string values (those are part of your data)
- Keys (every key is structurally meaningful)
- Boolean/null literals (those are tokens, not whitespace)
The output is byte-different from the input, but parser-identical: any JSON parser produces the same in-memory structure from either form.
Common Use Cases
- Reducing API response size. A REST or GraphQL server returning 100 KB of pretty-printed JSON sends 100 KB over the wire. Minified, that drops to 60–70 KB. With gzip on top, it falls further to 10–20 KB. For high-traffic endpoints, this directly cuts bandwidth bills and improves p95 latency on slow networks.
- Embedding in HTML data attributes. When server-rendered pages need to bootstrap a JS client with some state, the conventional pattern is
<script id="state" type="application/json">{...}</script>. Minifying keeps the page weight down. - JWT payloads. JWTs are size-sensitive (they go in HTTP headers, which have caps). Minifying the payload before signing keeps the resulting token compact.
- Cookies and localStorage. Both have size caps (around 4 KB for cookies, 5–10 MB for localStorage). Minification gives you more usable headroom.
- CI artifacts and logs. Build outputs and structured logs in JSON form benefit from minification before upload to artifact stores.
Minification vs. Gzip
A common question: if I'm gzipping anyway, why minify?
Gzip is a Lempel-Ziv-based compression algorithm. It finds repeated byte sequences and replaces them with shorter back-references. Whitespace in JSON tends to compress very well in gzip, long runs of spaces become tiny tokens. So if you only gzip, you might think minification is unnecessary.
But:
- Browsers receive HTTP responses post-gzip-decompression. The browser-side JSON.parse step sees the full size, and parsing 100 KB is slower than parsing 60 KB. Minifying speeds up parsing.
- Some transport layers (especially older proxies, some mobile carriers) don't gzip transparently.
- Storing minified JSON in a database means smaller rows, faster reads, smaller backups.
- Tokens like JWTs cannot be transparently gzipped because they pass through headers.
The pragmatic answer: minify always, gzip when the transport supports it. The combined savings beat either alone.
When Not to Minify
Minified JSON is unreadable. If a JSON file is checked into a repo for humans to read or edit (configuration files, fixtures, dev-only seeds), keep it pretty-printed. If it's an artifact or wire format, minify. The two are different roles for the same data.
A common pattern: store pretty-printed in the repo, minify at build time before deploy.
Validation as a Side Effect
The minifier parses your input before emitting output. If the input has any syntax error (missing comma, unbalanced braces, invalid escape sequence), you get a precise error message instead of silent corruption. This makes the minifier double as a fast JSON lint check, particularly useful when reviewing JSON snippets from logs or third-party APIs.
Local-First Privacy
The minifier runs in your browser. The JSON you paste stays on your machine. This matters when the JSON contains API keys, customer data, or proprietary schemas, pasting those into a server-side tool is a leak waiting to happen. Open DevTools → Network during a minify: zero requests fire.
A Note on JSON Variants
"JSON" is sometimes used loosely to mean JSONC (with comments), JSON5 (with trailing commas and unquoted keys), or NDJSON (newline-delimited). This minifier targets strict JSON (RFC 8259). For JSONC/JSON5, strip comments and unquoted keys first with a JSONC-aware preprocessor, then run the result through this minifier.
03 When Production Deploys Actually Benefit
Minification's value sharpens at the places where a single payload moves through size-constrained pipelines. These are the production scenarios where shaving even a few hundred bytes pays off measurably.
-
High-traffic API responses A REST endpoint serving 50M requests/day with 30KB pretty-printed responses ships ~1.5TB extra bytes daily versus minified. Gzip helps further, but you minify before compression so the compressor has less redundant whitespace to chew through and clients spend less CPU on JSON.parse.
-
SSR hydration payloads in HTML Next.js, Remix, and SvelteKit embed state inside
<script type="application/json">tags or HTML data attributes. Pretty-printed indentation inflates First-Contentful-Paint without any benefit, minify before the SSR boundary. -
JSON config in Docker ENV vars Kernel limits on environment-variable size (typically
ARG_MAX~128KB combined) and ECS task definition caps mean a fat pretty-printed config can break deploys. Minify before stuffing JSON intoENV CONFIG_JSON=.... -
JWT payload size pressure JWTs travel in HTTP headers, and many gateways (nginx default 8KB, ALB 16KB) cap header size. Minifying the payload before base64url encoding is often what keeps a chunky claims object under the wire limit.
-
AWS Lambda's 6MB response cap Lambda synchronous-invoke responses are hard-capped at 6MB. When a function returns a large aggregate (search results, report data), minification can be the difference between a successful response and a 502 from the runtime.
04 Worked Examples
{
"user": {
"id": "u_8a2f",
"email": "ada@example.com",
"roles": ["admin", "billing"],
"preferences": {
"theme": "dark",
"notifications": true
}
}
}
{"user":{"id":"u_8a2f","email":"ada@example.com","roles":["admin","billing"],"preferences":{"theme":"dark","notifications":true}}}88% reduction on this snippet. The savings are dominated by removing indentation runs, not by any single character. Bigger trees with deeper indentation amplify the ratio.
<script id="APP_STATE" type="application/json">
{"locale":"en-US","flags":{"newCheckout":true,"experimentalNav":false},"user":null}
</script>const state = JSON.parse(document.getElementById("APP_STATE").textContent);Using type="application/json" (not application/javascript) avoids XSS via </script> injection and lets the browser skip parsing the block as JS. Minification is essential since this contributes to FCP.
// Pipeline: pretty JSON → gzip -9 → S3 → CloudFront
// vs. minified JSON → gzip -9 → S3 → CloudFrontpretty + gzip: 2,140 bytes
minified + gzip: 2,098 bytes // ~2% savings, rounding noiseGzip's LZ77 stage already collapses long whitespace runs into tiny back-references. If your transport guarantees gzip and clients never see raw bytes, minification mostly pays back in parser speed, not transfer bytes. Browser JSON.parse still walks every byte post-decompression, that is the win you keep.
05 Related Tools
Minification is one slice of the JSON toolchain. These pair naturally when you are shipping JSON to production or debugging a payload that arrived wrong.
JSON Formatter
The inverse trip. When you receive a minified blob from production logs, expand it back to a human-readable form before diffing or editing.
JSON Schema Validator
Before you ship a minified payload over the wire, sanity-check it against the schema your consumers rely on, minification will not save a contract bug.
JSON Diff
When a minified response from prod looks "different" from staging, a structural diff cuts past the formatting noise and shows the real value changes.