← All tools
// Data / Developer

JSON Minifier online

Strip whitespace from JSON to minimise file size

JSON Minifier logo
by
CHUNKY
MUNSTER
// JSON input

How to Use the JSON Minifier

  1. Paste your JSON (pretty or otherwise) into the input panel.
  2. Click Minify — the parser validates, then re-serialises with no whitespace.
  3. Check the byte counts to see how much you saved.
  4. Click Prettify to reformat back with two-space indentation.

Minifying JSON properly means parsing it first. This tool runs JSON.parse on your input, then JSON.stringify with no indent argument — that gives you the smallest valid JSON representation and guarantees the output is parseable by every other JSON library on the planet. If your input is malformed, the parser tells you exactly which character broke and you get a chance to fix it before producing a useless minified blob.

How the JSON Minifier Works

Prettify uses the same round-trip with a two-space indent so you can flip back and forth while debugging API payloads. Byte counts are shown for the original and minified versions so you can see the saving directly. Note that this is strict RFC 8259 — JSON with comments or trailing commas (JSONC, tsconfig style) will be rejected; strip those before minifying.

Frequently Asked Questions

Why does this also validate the JSON?

Because it minifies via JSON.parse + JSON.stringify rather than regex. If your input is invalid JSON the parser will refuse it and report exactly where the error is, so you cannot accidentally produce "minified" output that no other parser will accept.

How much will minification save?

For typical pretty-printed JSON, expect 20–40% raw byte savings just from removing newlines and indent spaces. After gzip the savings shrink — gzip already compresses repeated whitespace very well — but the smaller raw size still wins on memory and parse time.

Will it preserve the key order?

Yes. JSON.stringify in modern JS engines preserves the insertion/parse order of string keys, which matches the order they appeared in your input. Numeric keys on objects are normalised to ascending integer order, per the spec.

Does it handle JSONC, comments or trailing commas?

No. This is strict RFC 8259 JSON — comments and trailing commas will fail validation. Strip those first if your file is JSONC (e.g. tsconfig.json).

Explore the full suite of Data tools and 290+ other free utilities at Chunky Munster.