JSON Minifier — Strip Whitespace, Shrink Payloads (Online, Free)
Minify JSON to the smallest valid form — remove whitespace, newlines, and indentation. Cuts payload size 30-60%. Runs entirely in your browser.
About JSON Minifier
A JSON minifier is a tool that removes every byte of optional whitespace — spaces, tabs, newlines, indentation — from a JSON document while preserving exact semantic equivalence. The ZTools JSON Minifier parses the input with the browser-native `JSON.parse`, then re-serializes via `JSON.stringify(value)` (no second argument), guaranteeing a single-line, byte-minimal output that any JSON parser on the planet will accept. Typical pretty-printed JSON shrinks 30-60% after minification, which directly reduces network transfer time, gzip-compression input cost, and JSON-payload storage in databases or caches.
Use cases
- Shipping API responses with smaller payloads. Many backend frameworks pretty-print JSON responses by default for human readability. Minifying before sending — especially for high-traffic endpoints, mobile clients, or pay-per-byte CDNs — cuts response size measurably and improves Time-to-First-Byte. A 12 KB pretty response often drops to 7 KB minified, then to 1.8 KB after gzip.
- Embedding JSON in URLs or query strings. When passing structured state through URL parameters (e.g. shareable filter sets, redirect-back payloads, OAuth state tokens), every byte counts because URLs have practical length limits (~2,000 chars in older browsers, 8 KB on most servers). Minify the JSON, then URL-encode the result. The combined output stays well under common length ceilings.
- Storing JSON in cache keys or columnar databases. Redis values, ClickHouse JSON columns, and BigQuery STRING fields all charge for storage by bytes. Minifying before write reduces storage cost and increases the number of keys per memory page. Combined with snappy or zstd compression, minified JSON often takes a fraction of the space of pretty-printed input.
- Embedding JSON in HTML data attributes or script tags. Front-end frameworks frequently embed initial-state JSON into the page via `<script type="application/json">` blocks (Next.js, Remix, Inertia). Minifying first keeps the HTML payload smaller, which helps Largest Contentful Paint (LCP) on slow connections.
How it works
- Paste JSON into the input pane. Drag-drop a `.json` file works too. Files up to ~50 MB on a desktop browser parse without UI lag.
- Click Minify. The tool calls `JSON.parse(input)` to validate, then `JSON.stringify(value)` with no indent argument. Whitespace between tokens disappears entirely.
- Verify the output is still valid. Optional: paste the minified output back into the formatter and pretty-print it to confirm round-trip equivalence.
- Copy or download. Single-line output appears in the right pane. Copy with one click or download as a `.json` file.
- Optionally pipe through gzip externally. For maximum wire savings, run minified JSON through `gzip -9` or `brotli -q 11`. The combined effect typically delivers 80-90% size reduction over pretty-printed input.
Examples
Input: {
"name": "ZTools",
"tools": 519,
"free": true
}
Output: {"name":"ZTools","tools":519,"free":true}
Original: 53 bytes. Minified: 41 bytes. ~23% savings on a tiny example; larger inputs save more.
Input: [{"id":1,"label":"alpha"},{"id":2,"label":"beta"}]
Output: [{"id":1,"label":"alpha"},{"id":2,"label":"beta"}]
Already minified — no change. The tool is idempotent: minifying minified JSON is a no-op.
Frequently asked questions
Does minification change the meaning of my JSON?
No. Minification only removes whitespace between tokens. Object key order, array element order, string contents, and number precision are all preserved exactly. `JSON.parse(minified)` returns a value `===` deep-equal to `JSON.parse(original)`.
How much smaller does JSON get after minification?
Pretty-printed JSON with 2-space indents typically shrinks 30-60%, depending on nesting depth. Heavily nested structures benefit most because every level adds indentation. Already-compact JSON (single-line, no extra whitespace) shows little improvement.
Is minified JSON harder for humans to read?
Yes — that is the entire point. For debugging, paste minified JSON into our JSON Formatter to pretty-print it instantly. For production transmission, ship minified; for local inspection, format on demand.
Should I minify JSON in my application?
For any JSON sent over the network, yes. Most HTTP frameworks expose a setting like `JSON.stringify(value)` (no indent) or `compact: true`. Combined with gzip/brotli at the transport layer, minified JSON is the optimal default for production APIs.
Can I minify JSON with comments?
Strict JSON does not support comments. If your input contains `//` or `/* */` comments, parsing will fail. Use JSON5 or JSONC tooling first to strip comments, then minify the cleaned output here.
Is the tool offline?
Yes — once loaded, the page works without a network connection. Open DevTools → Network and confirm there are no requests during minification.
Pro tips
- Minify before measuring real payload size — pretty-printed input gives misleading numbers.
- Combine minification with gzip or brotli at the HTTP layer for compounding savings.
- For configuration files committed to git, prefer pretty-printed (better diffs); minify only at build time.
- When debugging a minified blob, paste into JSON Formatter to read it; never edit minified JSON by hand.
Reviewed by Ahsan Mahmood · Last updated 2026-05-05 · Part of ZTools.
For the full,
formatted version of this page, please enable JavaScript and reload
https://ztools.zaions.com/json-minifier.