JSON Minifier

Home
JSON ToolkitAll tools
Indent:
Input
Output
34 lines · 782 bytesAll processing happens locally in your browser.

JSON Minifier

Minify JSON when payload size matters, or when you need a compact fixture or environment value without changing the data itself.

  • Only whitespace is intentionally removed — but large integers and duplicate keys do not survive the round trip.
  • The tool reports the resulting size reduction.
  • Validate first if you are unsure whether the input is valid JSON.

This tool runs entirely in your browser. Your JSON is not uploaded, stored, or logged.

When minifying helps

Use a minifier after the document is valid and you need a compact form: embedding JSON in an environment variable, shrinking a fixture committed to a repo, or reducing transfer size for a known payload shape.

Minifying is the inverse of formatting: it does not remove keys, rename fields, or compress values by design — it strips insignificant whitespace. Because it reparses the document, the round-trip caveats below still apply. Invalid JSON should be fixed in the validator before you minify.

How much minifying actually saves

Whitespace is often 10 to 30% of a hand-formatted document and almost nothing of a payload an API already serialized compactly. The saving depends entirely on what you paste: re-minifying an already-compact response returns the same bytes, and the tool reports no reduction rather than inventing one.

When transfer size genuinely matters, this is a rounding error beside the two things that move the number: sending fewer fields, and letting the HTTP layer gzip the body. Minify for storage and for embedding, not as a performance strategy.

Where a minified document belongs

A compact single line is the right shape in specific places:

  • An environment variable or CLI argument, where newlines are awkward or rejected outright.
  • A fixture committed to a repo, where a one-line change produces a readable diff instead of re-indenting a block.
  • A value pasted into a SQL statement, a JSON column, or a log line.
  • A snapshot test, where formatting noise would make the assertion churn on unrelated edits.
  • The reverse also holds: leave committed config files formatted. A minified config is one bad merge away from unreadable, and machines never read your repository.

The whitespace JSON actually allows

JSON permits whitespace only between tokens — around braces, brackets, colons, and commas. Whitespace inside a string is content and is preserved exactly, and no valid JSON number contains a space. That is why minification can strip every redundant character. It is not a byte-for-byte copy, though: like the formatter, this tool parses the document and re-serializes it, so the same round-trip losses apply — duplicate keys collapse to the last value, and integers beyond 2^53-1 are rounded. Keep the original when either could be present.

It also means minifying cannot rescue an invalid document: characters that are not whitespace are left where the parser found them, so a trailing comma or a single quote still fails first.

What minifying is not

It is not compression. Minified JSON is still plain text; the bytes are smaller only because spaces and newlines are gone, and the same document gzips to far less over the wire. If transfer size is the goal, turn on gzip or brotli at the server rather than minifying payloads by hand.

It is also not a way to make data safer to embed. Minification changes formatting, not access — a token in a minified string is just as exposed as one that is pretty-printed.

Frequently asked questions

Does minifying change my data?

For ordinary values, no — whitespace is the only thing intentionally removed. But the tool parses and re-serializes, so a duplicate key collapses to its last value and an integer beyond 2^53-1 is rounded. Check those two cases before replacing the original.

Should I minify or format first?

Validate first. Format when you need to read the document. Minify when you need the compact form for storage or transfer.

Does minifying JSON make my API faster?

Negligibly. HTTP compression (gzip or brotli) does the real work and should be on regardless. Minify for storage, environment values, and single-line fixtures, not as a performance tactic.

Is minified JSON still valid JSON?

Yes. Whitespace between tokens is optional, so removing it produces an equivalent document. If the input was invalid, minifying leaves it invalid.

Related

Support the free tools