Skip to content

JSON Minifier

Runs 100% in your browser — nothing is uploaded, nothing is stored.

Minification removes whitespace only. The data itself is never altered.

Minifying strips every byte of whitespace that sits between tokens, and leaves everything else exactly as it was. The tool reports the saving as both a byte count and a percentage, so you can decide whether the trade in readability is worth it before you commit the change.

It also works in the other direction. Switch Output to Formatted and the same box pretty-prints instead, which is useful when you have a minified line of production data and need to see what is inside it.

How to use this tool

  1. Paste the JSON you want to shrink into the top box. Indented, pretty-printed input gives the largest saving; already-minified input gives almost none.
  2. Click Minify. The result appears in the lower box, and the metric strip above shows the original size, the minified size and the reduction.
  3. Switch Output to Formatted (indent 2) when you need the readable version back. This is a single toggle rather than a separate tool.
  4. Click Copy result to take the output. If the input does not parse, the error appears instead of a result, so you cannot accidentally copy corrupted output.

What minification removes, precisely

The operation is narrower than the name suggests, and being precise about it prevents a common misunderstanding. Minifying removes whitespace that appears between structural tokens: spaces after colons, spaces after commas, and line breaks and indentation between members.

It does not touch:

  • Whitespace inside string values. In a value such as "Ada Lovelace" the space between the two words is data and survives intact. So does a string that is nothing but spaces.
  • Key order. The document is parsed and re-serialised, and the serialiser preserves insertion order, so nothing is alphabetised.
  • Numeric values. 12.50 stays 12.50 rather than becoming 12.5, because the parser retains the value and the serialiser writes it back consistently.
  • Escaped sequences. \n inside a string remains a two-character escape rather than being turned into a real newline.
  • Duplicate keys. They are not collapsed, though note that most parsers keep only the last occurrence when reading.

Because a parser sits in the middle of the operation, malformed input fails before any transformation happens. There is no path where you get a silently corrupted result.

How much you actually save, and when it is worth it

Saving depends entirely on how much whitespace was present to begin with. Realistic figures:

  • Deeply nested config with two-space indent — commonly 30 to 50 per cent. Every nesting level multiplies the leading whitespace, so deep structures save the most.
  • Shallow API responses — typically 10 to 20 per cent. Less indentation depth means fewer bytes to remove.
  • Already-compact JSON — close to zero. There is nothing left to take out, and the tool will report a saving in the low single digits at most.

Now the caveat that matters more than any of those numbers. If your JSON travels over HTTPS with gzip or Brotli enabled, minifying before sending saves very little. Both compression algorithms are extremely good at exactly this problem: they encode repeated runs of spaces and newlines as a single reference, so an indented document and a minified one arrive at nearly the same compressed size. Minify a pretty-printed payload and watch the transfer size in a browser network panel with and without the change — the difference is usually under a few per cent.

Where minification is genuinely worth doing:

  • Data written to disk or baked into a build. The saving is paid once and kept forever, with no compression layer to hide it.
  • Payloads sent without content encoding. Some internal services, message queues and IoT protocols skip HTTP compression entirely, and then the difference is the full 30 to 50 per cent.
  • Storage-limited environments. Browser localStorage, mobile app preferences and embedded device flash all have hard ceilings where every kilobyte counts.
  • Log output and line-delimited formats, where a record must fit on exactly one line.

Minify with a reason, in other words. Treating it as automatic good practice adds an unreadable artefact to your repository in exchange for a saving that gzip was already delivering.

The precision limit you should know about

JSON numbers have no type distinction between integers and floats, and the parser that handles them is the one built into your browser. That parser follows IEEE-754 double precision, which represents integers exactly only up to 2^53 — that is 9,007,199,254,740,992.

Beyond that the limitation bites. Twitter exposed this for years: post identifiers exceeded 2^53, and JavaScript clients that parsed them as numbers silently lost the low digits, so two distinct posts could appear to have the same ID. The fix was to serialise them as strings.

This is a property of JSON parsing in JavaScript rather than of minification specifically, and formatting has the same exposure. If your document contains identifiers, timestamps in nanoseconds, or financial values with more than fifteen significant digits, the safe pattern is to quote them as strings in the payload. Sometimes the value is already a string and code elsewhere is calling parseInt on it, which reintroduces the same problem.

Minification will not make this worse — the round trip through a parser is identical either way — but it will not warn you about it either, because the parser cannot tell that a large number was meant to be an identifier.

Minified JSON in practice: where you meet it

Minified documents are the default in most places JSON appears, which is why being able to expand one quickly is as useful as the ability to shrink it.

  • HTTP API responses. Virtually every production API returns minified JSON, because the cost of pretty-printing is paid by every client on every request. Copying a response into this tool is the fastest way to read it.
  • Build artefacts. Bundlers, source maps and manifest files are minified as a matter of course.
  • Package manifests. A published package-lock.json is often minified, making a dependency conflict hard to trace until you expand it.
  • Embedded configuration. Docker labels, Kubernetes annotations and environment variables frequently hold a single-line JSON blob.
  • Database columns. PostgreSQL jsonb, SQLite TEXT columns and document stores return minified output by default.

For reading rather than shrinking, the JSON Viewer is usually the better entry point, because a collapsible tree is far easier to navigate than a long flat block of indented text. Minify when you need the smaller artefact; view when you need to understand what is in it.

Is minifying worth it in your case?

How the JSON is usedCompressed in transit?Worth minifying
HTTP API responseUsually yes (gzip or Brotli)Marginally — low single digits
File written to disk or committedNoYes — the full saving persists
Internal service without content encodingNoYes — commonly 30 to 50 per cent
Browser localStorage or app settingsNoYes — quota is measured uncompressed
Log line or streaming recordVariesYes — one record must fit one line
Payload you have to read and edit by handNot relevantNo — keep it formatted

Frequently asked questions

What does minifying JSON actually remove?
Only insignificant whitespace: spaces after colons and commas, line breaks and indentation between members. The parser rebuilds the data and re-serialises it, so no key, value or ordering changes.
How much can I expect to save?
Deeply nested, two-space-indented configuration files commonly shrink by 30 to 50 per cent. Shallow API responses typically save 10 to 20 per cent. JSON that is already compact saves almost nothing, because there is nothing left to remove.
Does minifying break anything?
No, provided the input is valid JSON — which is why this tool parses before it transforms. Malformed input produces the parser error instead of a corrupted result, so there is no path to silent data loss.
Is minified JSON smaller once compressed?
Barely. Gzip and Brotli already collapse repeated whitespace very efficiently, so the compressed transfer size is nearly identical either way. Minify for payload size when compression is unavailable, for data written to disk, and for readability of logs — not as a substitute for enabling compression.
Are numbers or precision changed?
Values pass through the browser JSON parser, which follows IEEE-754 double precision. Integers beyond 2^53 can lose precision — but that is a limitation of JSON parsing in JavaScript generally, not of minification, and formatting a document has exactly the same exposure.
Does it remove duplicate keys?
No. JSON permits duplicate keys and the tool leaves them in place. Be aware that when the document is later parsed, most implementations keep only the last occurrence — so a duplicate key is worth fixing at the source, not at the minification step.
Can I get the formatted version back?
Yes. Set Output to Formatted (indent 2) and the same input is indented instead of collapsed. For more control over indent width, the JSON Formatter offers 1, 2, 4 and 8 spaces.
Will it minify a document with comments?
No. Comments are not permitted in JSON, so a document containing them fails to parse. If you are working with a JSONC configuration file, strip the comments first — the JSON Validator will tell you where each one is.
Scroll to Top