Skip to content
DeveloperRuns in your browser

JSON Minifier

Strip whitespace from JSON to make it as small as possible.

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.

Minification is the JSON equivalent of compilation: same semantics, fewer bytes, worse for humans. It matters 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.

What gets removed

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.

The compression 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.

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.