Skip to content
DeveloperRuns in your browser

JSON Minifier

Strip whitespace from JSON to make it as small as possible with this JSON minifier.

Input
No upload needed — instant
Privacy
Nothing is uploaded
Cost
Free · no sign-up · no watermark

Loading tool…

The tool is loading its code on your device. This happens once and is cached for later visits.

Processed entirely on your device

Everything you type or paste is handled by JavaScript running in this tab. No request is sent, nothing is logged and nothing is stored. Close the page and it is gone.

Overview

About the JSON Minifier

Minify JSON online — remove indentation, line breaks and unnecessary whitespace without changing a single value. Shows the exact byte saving.

A JSON minifier strips every byte that does not carry meaning. Minification is the JSON equivalent of compilation: same semantics, fewer bytes, worse for humans. A JSON minifier earns its place in three situations — a payload embedded in a length-limited field, a document stored at scale where whitespace adds up, and any JSON crossing a network boundary that cannot compress. For reading, pair it with a formatter; for shipping and storing, the minified form is the correct one.

The numbers make the case quickly. Pretty-printed JSON written with two-space indentation typically shrinks by 20 to 40 percent when you minify it, and deeply nested documents written with four-space or tab indentation can shrink by half. Because this JSON minifier parses and re-serialises rather than running a blind whitespace strip, every one of those saved bytes is guaranteed to be semantically insignificant — and the before and after byte counts are shown, so the JSON compression is a number you can see rather than a guess.

What a JSON minifier removes

JSON's grammar allows insignificant whitespace in exactly four places: before and after any of the structural characters { } [ ] : ,. That is the entire surface a minifier touches. Everything else — every character between the quotes of a string — is data and must survive byte-for-byte.

This tool parses the document and re-serialises it rather than running a whitespace-stripping regular expression. That distinction is important: a regex approach will corrupt a document containing "message": "a, b\n c", because the spaces and escaped newline inside that string are indistinguishable from formatting whitespace to a pattern that does not understand string boundaries.

Minify JSON or let gzip do it — the transport caveat

If your JSON travels over HTTP with gzip or Brotli enabled — and it almost certainly does — minification saves far less than the raw byte count suggests. Whitespace is extremely compressible: repeated indentation is exactly the kind of redundancy those algorithms excel at. In practice, minified-plus-gzipped and pretty-plus-gzipped are often within a few percent of each other.

Minification still matters when:

  • the payload is stored uncompressed, in a database column, a key-value store or a config field;
  • the transport cannot compress, such as a WebSocket frame, an MQTT message or a query parameter;
  • there is a hard character limit, as with some serverless environment variables, SMS gateways or embedded systems;
  • you are paying per byte at the edge and the volume is high enough for a few percent to be worth capturing.

A note on precision

Because minification goes through the JavaScript parser, the same big-integer caveat as the formatter applies: numeric literals above 2^53 − 1 will lose precision. If your document contains snowflake IDs or other very large integers, verify the output against the input before relying on it, or handle those fields as strings at the source.

Compact JSON is the transport format

Every mainstream serialiser produces compact JSON by default: JSON.stringify in JavaScript, json.dumps with default separators in Python, Go's encoding/json, Jackson and Gson in the Java world. Pretty-printing is a debugging affordance, not a transport format, and you should never deliberately send indented JSON over the wire. If you capture request and response bodies for logs or replay, keeping the compact form and formatting it on demand is the cheaper habit; the reverse — storing pretty text and re-minifying on every read — wastes both space and cycles.

Where minified JSON is expected

  • Squeezing a config payload under an environment-variable or URL length limit before deployment.
  • Shrinking seed data or fixtures that live in a repository where the pretty form dominates the diff history.
  • Preparing JSON for a single-line context: an SMS deep link, a QR code payload, a WebSocket message, an MQTT topic payload.
  • Trimming large exports from a database or analytics system before archiving them uncompressed.
  • Reducing the size of embedded payloads in firmware or game data, where every kilobyte of flash costs money.

Is minified JSON safe to edit?

You can edit it, but you should not enjoy it. A single-line document hides the nesting structure that indentation makes visible, and a JSON minifier is deliberately not an editor. The professional pattern is to keep a readable source, minify a copy for shipping, and reformat whenever a human needs to look. Minified JSON is for machines; formatted JSON is for people; the translation between them should always be one keystroke — which is exactly why the formatter and the minifier exist as a pair.

A JSON minifier that validates first

Because this tool parses before it re-serialises, invalid input produces a positioned error instead of a silently mangled payload. That matters more than it sounds: the classic production incident is a hand-edited document that was whitespace-stripped without validation and shipped with a structural error that no parser caught until runtime. Validation-first minification closes that hole — you can batch-compact a folder of config files and know that any document which fails to minify was already broken before you touched it. Everything happens in your browser, so the payloads you compress, including the ones carrying tokens and internal hostnames, never travel to a server.

Step by step

How to use the JSON Minifier

  1. Paste the pretty-printed JSON you want to compact.

  2. Press Minify; the parser validates first, so broken input is reported rather than mangled.

  3. Compare the input and output byte counts to see the saving.

  4. Copy the minified string, or download it as a compact .json file.

Why use it

Benefits and common use cases

What this tool is good for, and what it deliberately does not try to do.

Guaranteed semantic equivalence

Minification works by parsing and re-serialising, so whitespace inside string values is never touched — only the insignificant whitespace between tokens is removed.

Validates before compacting

Invalid JSON produces a positioned error instead of a silently broken payload, which is the failure mode that causes production incidents.

Shows the real saving

Reports bytes before and after, so you can judge whether the compaction is worth it for a given payload.

Useful for constrained targets

Configuration fields, URL query parameters, environment variables and embedded-device payloads all have hard length limits that pretty-printed JSON blows through.

Questions

Frequently asked questions

Short, honest answers about quality, limits and privacy.

Does minifying JSON change its meaning?

No. Whitespace between tokens is insignificant in JSON, so removing it produces an equivalent document. Whitespace inside string values is preserved exactly, because it is part of the data.

How much smaller does JSON get when minified?

Typically 20–40% for a document formatted with two-space indentation, and more for deeply nested structures with four-space or tab indentation. Gzip or Brotli compression in transit removes most of that difference, which is why minification matters less over HTTP than it used to.

Should I minify JSON in an API response?

Yes — you should never send pretty-printed JSON over the wire. Every mainstream serialiser produces compact output by default; pretty-printing is a debugging affordance, not a transport format.

Is minified JSON harder to debug?

Considerably, which is why the two tools exist as a pair. Minify for storage and transport, format for reading. Never keep only the minified version of something a human will need to inspect.

Does minification remove keys with empty values?

No. That would change the data. An explicit null, an empty string, an empty array and a missing key are all semantically different, and a minifier has no business collapsing them. Pruning empty fields is a separate, application-level decision.