📉

JSON Minifier

Minify JSON by stripping all unnecessary whitespace. Typically 15–30% smaller with zero data loss. Free and runs in your browser.

✓ Free forever✓ No signup✓ 100% private — runs in your browser
JSON Formatter & Validator
Format, validate, minify, compare and explore JSON. Supports files up to 10MB.
Format
Compare
Tree View
Query (jq-like)
Input JSON
Output
Formatted output appears here…

Formatted JSON is full of whitespace that exists purely for human readers — indentation, line breaks, spaces after colons. A parser ignores all of it. Stripping it before transmission or storage is free savings.

How to use the JSON Minifier

  1. Paste your formatted JSON
  2. Click Minify
  3. Check the before and after sizes
  4. Copy the minified output

How much you actually save

It depends on the shape of the data. Deeply nested structures with short values have proportionally more indentation, so they compress most — 30% or more is common. Documents dominated by long string values save less, often under 10%, because the strings themselves are untouched.

Worth knowing: if your server already applies gzip or brotli, the extra win from minification is much smaller, because those algorithms compress repeated whitespace very efficiently. Minify anyway for data you store at volume or embed in another document, but do not expect dramatic gains on an already-compressed HTTP response.

When to keep JSON formatted

Anything a person edits or reviews should stay formatted: configuration files, fixtures, seed data, anything in version control. A minified file produces a single-line diff for every change, which makes code review essentially impossible.

The rule of thumb is simple — minify what machines read, format what humans read.

Where minified JSON belongs, and where it does not

Minifying is right whenever a machine is the only reader and the bytes cost something.

Worth minifying: API responses, especially paginated lists where the saving multiplies; payloads stored at volume in a database column or a cache; anything embedded in a URL or a header, where length limits are real; JSON written into HTML as an inline data island.

Not worth minifying: configuration files that humans edit, such as package.json or tsconfig.json — the diff noise alone outweighs the bytes. Fixture files in a test suite, for the same reason. Anything in version control that people review, since a minified file shows every change as one modified line.

The general rule is that whitespace costs bytes once and costs review time every day. Where a file is read by people, keep it formatted; where it crosses a wire, strip it.

Minification against compression

A reasonable objection: if the server already gzips responses, is stripping whitespace worth anything? Repeated spaces and newlines are exactly what a compressor handles best, so most of the benefit should already be captured.

Largely true, and minification still helps for three reasons.

Compression is not always on. Content below a size threshold is often served uncompressed, internal service-to-service calls frequently skip it, and a misconfigured proxy can strip the header.

The uncompressed size is what gets stored and parsed. A payload cached in memory, written to a database column, or held in a queue occupies its real length, not its compressed one. The parser also walks every byte.

The saving compounds at the margins. Minifying before gzip typically still removes a few percent of the compressed output, which on a high-traffic endpoint is real bandwidth.

So: minify and compress. They are not alternatives, and the cost of doing both is nothing.

Checking that minified output is still valid

Minification should be a safe transformation, and it is worth confirming rather than assuming — particularly when the input came from somewhere you do not control.

The quickest check is to parse the output. Running the minified result back through a formatter either reproduces your structure or reports an error at a specific position. If it round-trips, the minification was clean.

Two things are worth watching for.

Whitespace inside strings must survive. {"note": "hello world"} keeps both spaces, because they are data rather than formatting. A minifier that strips them is broken, and the symptom is subtle — text that renders with words run together, long after the minification step.

Escaped characters must stay escaped. A string containing \n holds two characters, a backslash and an n, which the parser turns into a newline. Confusing the literal and the escape is the classic way to corrupt JSON while apparently only removing whitespace.

Comparing the parsed objects — rather than the text — before and after is the definitive test, and it is what any minifier worth using does in its own test suite.

Frequently asked questions

Does minifying lose any data?

No. Only insignificant whitespace is removed. Parse the minified output and you get an object identical to the original in every respect.

Can I reverse it?

Yes — formatting the minified JSON restores readable indentation. The two forms are fully interchangeable.

Is whitespace inside string values removed?

No, and it must not be. Whitespace inside a quoted string is part of the data. Only whitespace between tokens is stripped.

Should I minify if my server uses gzip?

The additional saving is small, because gzip already handles repeated whitespace well. It is still worth doing for data stored in bulk or embedded in other documents.