JSON Minifier (Compress JSON)
100% in your browser
Your data is never uploaded. All processing happens locally on your device.
Read privacy policy →Keyboard shortcuts
Last updated: 2026-09-17
Paste formatted JSON to minify it and see the exact byte savings. The tool also estimates the gzip-compressed size so you know the real transfer cost. Everything runs locally in your browser.
What this tool does
Takes formatted JSON and removes all unnecessary whitespace, producing the smallest valid JSON representation. The tool shows the original byte count, the minified byte count, the percentage saved, and an actual gzip-compressed size estimate using the browser’s CompressionStream API.
The pipeline is straightforward: the input string is parsed with JSON.parse, then re-serialized with JSON.stringify and no spacing argument, which emits tokens with no whitespace between them. Byte counts are measured by wrapping the strings in a Blob and reading its size property. The gzip figure comes from piping the minified output through a CompressionStream('gzip') stream and summing the resulting chunks.
Example
Input (formatted, 98 bytes):
{
"name": "myapp",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.0"
}
}Output (minified, 64 bytes):
{"name":"myapp","version":"1.0.0","dependencies":{"express":"^4.18.0"}}The tool reports: raw 98 bytes, minified 64 bytes, saved 34.7%, gzip ~71 bytes.
When minification matters
Minification matters most for large JSON payloads delivered over a network. A 1MB API response with generous formatting may shrink to 600KB after minification and to 80KB after gzip. For small JSON files (under 10KB), the savings are negligible and readability is more important. The crossover point depends on the transport: on a gigabit LAN the transfer cost of extra whitespace is trivial, while on a satellite uplink or a dial-up fallback the same bytes add noticeable latency. Cache and CDN storage also factor in, because many edge nodes bill by stored bytes, so shrinking a frequently cached response lowers both egress and retention costs over time.
Minifying API responses
API responses are the most common reason to minify JSON. A single endpoint that returns a list of records can easily reach hundreds of kilobytes when pretty-printed, and that overhead is paid on every request.
Consider an endpoint returning 1,000 product records. Pretty-printed with 2-space indentation, the response body is around 480 KB. After minification it drops to roughly 310 KB, and with gzip applied to the minified body it compresses further to about 42 KB. On a mobile connection averaging 400 KB/s, the formatted version takes 1.2 seconds to transfer, the minified version takes 0.78 seconds, and the gzipped minified version takes 0.11 seconds. The wire time difference between formatted-plus-gzip and minified-plus-gzip is smaller but still measurable, because gzip has less redundant whitespace to exploit once minification has already collapsed it.
For paginated endpoints, the savings compound. If a client fetches 50 pages of 20 records each, shaving 170 KB off every response removes 8.5 MB of transfer across the full traversal. That matters on metered connections and on server egress budgets.
Minifying vs gzip
Minification and gzip solve overlapping but distinct problems, and they work at different layers.
Minification is a structural transformation applied to the text itself. It removes characters that carry no semantic meaning — spaces, tabs, newlines, and indentation — so the resulting string is a smaller but equivalent JSON document. The output is still JSON text; a parser reading it produces the same data structure. The reduction is bounded by how much whitespace the original contained, typically 15% to 40% for human-formatted input.
Gzip is a compression algorithm applied to the bytes on the wire. It finds repeated byte sequences and replaces them with short references, so a document with many repeated keys like "id", "name", and "created_at" compresses well regardless of whether it was minified first. Gzip operates transparently at the HTTP transport layer when the server sets Content-Encoding: gzip and the client sends Accept-Encoding: gzip.
The two techniques interact. Gzip already encodes repetition very efficiently, so minifying before gzip yields a smaller compressed result than gzipping the formatted version, but the extra gain is usually modest — often 5% to 10% on top of the gzip savings alone. The cases where minification matters most even with gzip enabled are small responses where the gzip header overhead is significant relative to the payload, and embedded or constrained clients that decompress but cache poorly.
Rule of thumb: enable gzip on your server first, because it gives the largest single win. Add minification when you control the producer and want to reduce both raw storage size and the gzipped transfer size, or when the consumer cannot use gzip.
When minification hurts
Minification is not always the right choice. There are concrete cases where it makes things worse or provides no benefit.
Human-readable files under active editing. Configuration files, test fixtures, and hand-written schemas are read and modified by people. Minifying them destroys diffs: a one-field change shows up as a change to the entire single-line document in version control. Keep these formatted and rely on gzip for transfer.
Already-minified input. Running the tool on JSON that has no whitespace produces zero savings and just rewrites the bytes. The tool detects this and reports 0%, but there is no reason to add the step to a pipeline.
Tiny payloads where gzip is enabled. Below roughly 1 KB, gzip overhead can exceed the whitespace savings, and the difference between formatted and minified is a few dozen bytes. The optimization is not worth the loss of debuggability.
Logs and audit trails that humans scan. When operators read JSON logs in a terminal or text viewer, minified single-line output is hard to scan. Many log viewers re-format on display, but if yours does not, minification slows incident response.
When the consumer re-serializes immediately. If the client parses the JSON and writes it back out with its own formatting, the minified form never reaches an end user. The only benefit is a small transfer-time reduction, which may be irrelevant on a fast internal network.
Common mistakes when minifying
- Assuming minification replaces gzip. It does not. Minification removes whitespace; gzip removes byte-level redundancy. Use both when the transport supports it.
- Minifying then base64-encoding for transport inside another JSON field. Base64 expands the payload by 33%, which can wipe out the whitespace savings. Consider a binary format or a separate endpoint instead.
- Comparing byte sizes across tools that count differently. This tool measures bytes with a
Blob, which counts UTF-8 encoded bytes. A tool counting UTF-16 code units will report different numbers for the same string. - Minifying JSON that contains long prose strings. Whitespace inside string values is preserved by minification, so a document full of human-readable text barely shrinks. Compression, not minification, is what helps there.
- Forgetting that
JSON.parsedrops duplicate keys. If your source relies on duplicate keys as a quirk, minification will silently keep only the last value. Validate this before shipping. - Running minification on every request server-side instead of caching the result. The parse and stringify pass is cheap but not free at high throughput; cache the minified output.
- Treating the gzip estimate as the exact on-wire size. Server gzip headers, compression level, and chunked encoding boundaries all shift the real number by a few bytes.
- Minifying error responses that are only generated on failure paths. They are rare and usually read by developers, so formatting helps more than size helps.
Understanding the byte savings report
The report has four numbers, each measuring something different.
Raw bytes. The size of the original input string encoded as UTF-8, measured by constructing a Blob from the string and reading its size property. This is the exact number of bytes the formatted document occupies on disk or in memory before any processing.
Minified bytes. The size of the output after JSON.parse and JSON.stringify with no spacing argument. Same measurement method: Blob size in UTF-8 bytes. The difference between raw and minified is pure whitespace removal.
Saved percentage. Computed as (raw - minified) / raw * 100, rounded to one decimal place. A file with no whitespace reports 0.0%. Because the formula divides by the raw size, a small file with a lot of indentation can show a high percentage while saving only a few bytes, so read the percentage alongside the absolute byte counts.
Gzip estimate. The size of the minified output after being passed through CompressionStream('gzip'). This is a real gzip of the minified bytes, not a formula. It tells you what the transfer size would be if the server applied gzip to the already-minified document. Compare it against gzipping the raw input to decide whether minification adds value on top of compression for your specific payload.
The percentage reflects only whitespace savings, not compression. A document that minifies by 35% and then gzips by another 70% does not save 105%; the two reductions apply sequentially, so the final size is roughly 0.65 times 0.30, or about 19.5% of the original.
Minifying for embedded systems
Embedded devices, microcontrollers, and IoT gateways often fetch configuration or telemetry schemas over constrained links — cellular, LoRaWAN, or low-power Wi-Fi with tight duty cycles. On these links every byte costs airtime and battery, and many clients lack a gzip decompressor entirely because the decompression code would not fit in flash alongside the application.
In that environment, minified JSON is not a nicety but a practical wire format. A weather station posting a 220-byte formatted reading over LoRaWAN may be over the 51-byte payload limit for its data rate; minified, the same reading is around 140 bytes, and with shorter keys it can fit. The tool’s gzip estimate tells you when compression would help, and the raw minified size tells you what you actually send when the client cannot decompress.
Constrained devices also benefit from predictable parsing. Minified JSON from JSON.stringify has a stable shape: no optional whitespace, no trailing commas, consistent quoting. Embedded JSON parsers, which are often handwritten and brittle, handle the predictable form better than arbitrarily formatted input.
For devices that do support gzip, the report’s gzip estimate lets you budget the decompression RAM. A minified body of 40 KB that gzips to 9 KB tells you the device needs buffers for both the 9 KB compressed stream and the 40 KB inflated result, which matters on parts with 64 KB of RAM.
Do it in code
JavaScript:
const minified = JSON.stringify(JSON.parse(input));
// No second/third argument = no whitespacePython:
import json
minified = json.dumps(json.loads(input), separators=(',', ':'))
# The separators argument removes spaces after , and :CLI:
# jq (compact mode)
echo '{"a": 1, "b": 2}' | jq -c '.'
# Python one-liner
echo '{"a": 1, "b": 2}' | python -c 'import json,sys; print(json.dumps(json.load(sys.stdin)))'Edge cases handled
- Unicode characters are preserved in the minified output.
- Numbers, booleans, and null values are not modified — only whitespace is removed.
- Already-minified JSON is handled gracefully (no change, 0% savings reported).
- The gzip estimate uses the browser’s native CompressionStream API when available, and falls back to reporting raw size when it is not.
- Empty objects and arrays are preserved as
{}and[], not removed. - Non-ASCII string content is kept verbatim; the tool does not escape Unicode into
\usequences, so multilingual data stays compact.