JSON Minifier

Paste or upload JSON to strip whitespace without changing data. Runs in your browser.

Pasted text and chosen files stay on this device. Nothing is sent to a server.

Drop a file here, choose one, or paste.

No output yet Minify to see the result here.

How to use it

  1. 1

    Paste the JSON.

  2. 2

    Read the two byte counts to see what was actually saved.

What it does

Minifying removes the whitespace JSON allows between tokens. It changes nothing else, which is the whole property worth checking: parse the output and it must equal the input.

Parse the input, re-serialise with no insignificant whitespace, and report the byte count before and after.

Why it works this way

The whitespace inside a JSON string is data and is preserved. Only the whitespace between tokens is removable, and a minifier that strips inside strings corrupts the payload in a way that still parses.

Minifying is not compression. It removes the whitespace a human added; it does not encode anything. For real size reduction the transport should compress, and this is what is left after that.

The saving is largest on data that was pretty-printed with a wide indent, and zero on JSON that was already on one line — which is why the byte counts are shown rather than a claim about size.

Examples

{
  "a": 1,
  "b": [2, 3]
}
{"a":1,"b":[2,3]}
21 bytes removed, none of them inside a string
{"note": "a  b"}
{"note":"a  b"}
the two spaces inside the string are data and stay

Inputs and outputs

  • JSON text
  • the minified JSON
  • bytes before and after

Edge cases

  • whitespace inside strings
  • already minified — byte counts equal, which is a correct result not a failure
  • numbers with exponents and trailing zeros — must not be reformatted

Frequently asked questions

Does it shrink my payload much?

Only by the indentation. If the JSON was already on one line the saving is zero, and the byte counts will say so.

Is the output still valid JSON?

Yes, and it parses to the same value. That equality is the property to check, not the size.

Related tools

Sources

  • RFC 8259, section 2 (insignificant whitespace)