JSON Minifier

Strips every byte of insignificant whitespace from JSON, producing the smallest spec-compliant form of the same data. It parses your input first, so anything invalid is reported as an error rather than silently mangled.

Live demo · real result from this tool

Minified JSON

{"id":1024,"name":"Asha Rao","email":"asha@example.com","active":true,"roles":["admin","editor"],"address":{"city":"Pune","postcode":"411001"},"lastLogin":null}
Saved17.9%
Original size
195 B
Minified size
160 B
Bytes removed
35

Processed on your device — nothing is uploaded.

How to use JSON Minifier

  1. Paste the JSON you want to compress.
  2. The minified output appears immediately, with the before and after byte counts.
  3. Copy the result, or fix the reported syntax error if the input would not parse.
  4. JSON has no comments. If your file has // or /* */ in it, it is JSONC or JSON5 and will fail to parse here — strip the comments first.
  5. Integers beyond 2⁵³ lose precision when parsed, because JSON numbers become IEEE-754 doubles. Large IDs should travel as strings.
  6. Everything runs in the browser, so API responses and config files with credentials in them are never transmitted.

Minifying is parse-then-restringify, not find-and-replace

The tool runs your text through a real JSON parser and re-serialises the result with no indentation. That matters, because a regular expression that deleted whitespace would also delete the spaces inside your string values. It also has consequences worth knowing before you diff the output against the input: key order is preserved, but duplicate keys collapse to the last occurrence, and numbers come back in JavaScript’s canonical form — 1.0 becomes 1, 1e3 becomes 1000, and 0.30000000000000004 stays exactly that. The upside is that the output is guaranteed to be valid JSON.

How much you actually save, honestly

Pretty-printed JSON with two-space indentation is typically 15–30% whitespace, and deeply nested structures with short values are at the high end. But whitespace is the single most compressible thing in a file: once gzip or Brotli has run over it, the difference between minified and formatted JSON is usually a couple of percent. Minifying pays off where the JSON is stored or embedded uncompressed — localStorage quotas, a data attribute in HTML, a database column, an environment variable, the payload of a QR code, a URL fragment.

What it deliberately does not do

It does not shorten or rename keys, strip null or empty values, reorder anything, or change your structure in any way. Minification is purely a change of representation, and it is fully reversible — running the output through the JSON formatter gives you an indented document back. If you need the payload genuinely smaller rather than merely tidier, that is a schema problem: shorter key names, or a binary format such as MessagePack or CBOR.

Frequently asked questions

How much does minification reduce size?
Typically 20–40%. Deeply indented JSON with long keys benefits the most.
Is minified JSON still valid?
Yes — whitespace is not meaningful in JSON. Minified JSON is fully spec-compliant.
Should I minify production API responses?
Yes — always minify JSON in production APIs to reduce bandwidth.
Does minifying change my data?
The values stay the same, but their representation can be normalised: numbers are re-emitted in canonical form, escape sequences in strings may be written differently, and duplicate keys — which JSON permits but nothing sensible relies on — collapse to the last one. If you need a byte-for-byte reversible round trip, do not minify.
Will minified JSON break my API or parser?
No. Whitespace between tokens carries no meaning in JSON, so every conforming parser reads the minified form identically. It is only harder for humans.
Is it worth minifying if my server already gzips responses?
For bandwidth, barely — compression removes almost all of what minification would have removed. It is still worth it for anything stored uncompressed, and it slightly reduces the work the parser does on very large documents.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close