Input

Minified Output

Minified JSON appears here

Paste or type JSON in the panel on the left and the whitespace comes out as you go.

How Much Whitespace Is Actually in There

Minifying JSON is not a clever transformation. It parses the document, serialises it again with no indent argument, and every space, tab and newline that existed only for your benefit disappears. That is safe because the grammar says so: RFC 8259 §2 permits whitespace between any two tokens and gives it no meaning, which is exactly why it can all be deleted — and why the same is emphatically not true of YAML, where indentation is the structure. What is worth knowing is how much stripping it buys, because the numbers repeated around the web — "up to 70% smaller" — describe a file that was mostly indentation, and most files are not.

Take the Call Detail Record in the example below. Pretty-printed at two spaces it is 328 bytes over 20 lines; minified it is 213 bytes on one line. That is a 35.1% reduction, and it is high rather than typical, because the record is five levels deep and its keys are short — indentation cost is driven by nesting depth, not by how much data you have. Flatten the same record into six top-level keys and the saving falls to about 14%. Nothing is wrong in either case; the ratio is just a fact about shape.

The honest caveat, and the reason to be sceptical of the 70% figure: if the document travels over HTTP it is almost certainly gzipped, and gzip is extremely good at repeated runs of spaces. The same record compresses to 201 bytes pretty-printed and 171 bytes minified — so minifying saved 115 raw bytes but only 30 on the wire, about 15%. Minify because a compact payload is easier to log, embed and store, not because you are expecting a bandwidth win that HTTP compression has usually already taken.

Minifying a Document

  1. Paste or upload one file – Paste into the left panel, or use "Upload" to pick a single .json file — it is pretty-printed into the input pane first so you can still read it. One file at a time; there is no batch mode here.
  2. Read the right panel – Minification runs about a third of a second after you stop typing. If the input does not parse, you get the invalid-JSON panel with a line and column instead of output — nothing half-minified is ever shown.
  3. Check the values, not just the length – Scan any long identifiers in the output. Integers are carried through as text, so a 19-digit ICCID keeps all 19 digits; decimals are re-printed in shortest form, so 1.50 comes out as 1.5.
  4. Copy or download – "Copy" puts the single line on your clipboard; "Download" saves it as minified.json. Both read the output pane, so what you get is what you can see.

Pro Tip: Minify last, not first. A minified file is unreadable in a diff, so keep the formatted copy in version control and minify on the way out — the JSON Formatter reverses this exactly, and the round trip is safe in both directions.

Example

A Call Detail Record with two handover entries, at the two-space indentation almost every tool emits. Both blocks below are real output, not typed by hand: 328 bytes across 20 lines becomes 213 bytes on one line. That is 115 bytes saved, or 35.1% — high for a JSON document, and it is the nesting that earns it.

Formatted → Minified 328 B → 213 B
cdr.jsonJSON · 20 lines · 328 B
{
  "cdrId": "CDR-2026-06-24-0001",
  "msisdn": "447700900142",
  "durationSec": 187,
  "chargeable": true,
  "radio": {
    "cellId": "AB12-3CF",
    "rsrp": -92,
    "handovers": [
      {
        "cellId": "AB12-9D1",
        "atSec": 74
      },
      {
        "cellId": "AB13-1A0",
        "atSec": 151
      }
    ]
  }
}
cdr.min.jsonJSON · 1 line · 213 B
{"cdrId":"CDR-2026-06-24-0001","msisdn":"447700900142","durationSec":187,"chargeable":true,"radio":{"cellId":"AB12-3CF","rsrp":-92,"handovers":[{"cellId":"AB12-9D1","atSec":74},{"cellId":"AB13-1A0","atSec":151}]}}

Common Use Cases

Embedding a document in something else

A config blob going into an environment variable, a fixture pasted into a test, a payload that has to sit on one line inside a log entry — all of these break or read badly when the JSON carries newlines. Minifying is the fix, and here the saving is beside the point: what you wanted was one line. Pair it with the JSON Escape tool when the destination is itself a JSON string.

Trimming what you store, not what you send

Whitespace in a database column, an object-store key or a message queue payload is stored and paid for verbatim, often without compression in front of it. That is where the 35% in the example above is a genuine 35%. Over HTTP, where gzip or brotli is doing most of the work already, expect closer to 15%.

Making two files comparable

Two services claim to emit the same document but one indents with four spaces and the other with tabs, so a byte comparison is useless. Minify both and the difference that remains is a real difference — the token sequence the JSON grammar actually defines, with the cosmetic layer taken off. For the field-by-field answer, take them to JSON Diff.

Worth Knowing

  • It validates before it minifies – A document that does not parse produces the error panel with a line and column, never a partially stripped output. There is no way to get half a result out of this page.
  • Long integers survive – Number literals are read out of your source text rather than converted to JavaScript numbers, so 8901240544102066246 stays exact instead of rounding to 8901240544102066000 the way a plain JSON.parse round trip does.
  • Decimals are re-printed, not preserved – The one thing minifying does change beyond whitespace: 1.50 becomes 1.5, 1.0 becomes 1 and 1e5 becomes 100000. Same numbers, different text — do not diff a minified file against a hand-written one and expect silence.
  • Duplicate keys collapse – JSON permits them and every parser keeps the last, so {"a":1,"a":2} minifies to {"a":2} with no warning. Worth checking if your input was assembled by string concatenation.
  • One file at a time – Upload takes a single file. There is no batch queue and no folder mode — for a directory of documents, a shell loop over your own JSON tooling is the right instrument.
  • Nothing is uploaded – Parsing and serialising both run in this tab. Load the page, disconnect, and it still works.

Frequently Asked Questions

Does minifying change my data?

Structure and strings, no. Numbers, in one narrow sense, yes: integers are preserved literally however long they are, but a decimal or exponent is re-printed in the shortest form that round-trips, which is the behaviour JSON.stringify is specified to have — so 1.50 becomes 1.5 and 1e5 becomes 100000. The values are identical, the text is not. String contents and nesting come through untouched, and the minified document parses to exactly what the formatted one did — with one JavaScript quirk to know about: keys that look like array indices are re-sorted ahead of the rest, so {"20":…,"3":…} comes back with "3" first.

How much smaller will my file get?

Measure it rather than trusting a headline. The example on this page is 35.1%, and that is on the generous side because the document is deeply nested with short keys. A flat record of the same size gives about 14%. Long string values dilute the ratio further — a payload that is mostly prose barely moves, because there was hardly any whitespace in it to begin with. The one reliable rule: saving tracks nesting depth, not file size.

Is it worth minifying if my server already gzips?

Usually not for bandwidth. Measured on the example document, gzip takes the formatted copy to 201 bytes and the minified copy to 171 — the minifying step is worth about 15% once compression has done its work, because runs of identical spaces are the easiest thing a compressor will ever meet. It is still worth doing when the file is being stored uncompressed, embedded in another document, or written to a log.

Can I minify invalid JSON?

No, and that is deliberate — stripping whitespace from a document you have not parsed can change what it means. Fix the input first: the error panel gives you a line and column, the JSON Validator explains it in more detail, and Stack Overflow's JSON tag covers the unusual ones.

Does anything leave my browser?

No. The document is parsed and re-serialised by code in this tab; nothing is sent, stored or logged, and a file you pick with Upload is read locally and discarded when you close the tab.

Related Tools