Skip to main content

JSON Minifier

Remove whitespace from JSON to make it as small as possible. Click Minify

14
Loading editor…

What minifying does and does not change

Only whitespace outside strings is removed. Everything inside a string, including spaces, tabs and escape sequences such as \n, stays as it is, and numbers are not reformatted, so a value like 12345678901234567890 comes out unchanged. Keys keep their order. The minified text parses to exactly the same data as the original.

The tool checks the JSON before minifying. If it is invalid, the errors are shown with their line and column and nothing is changed, because minifying broken JSON only hides where it is broken.

Minifying is not compression. A web server's gzip or Brotli shrinks JSON much further, and works on minified and pretty-printed JSON alike; minifying mainly helps when the text is stored or sent without compression, such as in a URL parameter, an environment variable, a database column or a test fixture.

Minifying JSON in your own code

In JavaScript, JSON.stringify(JSON.parse(text)) returns minified JSON, but it parses the numbers: integers beyond 9007199254740991 lose precision. In Python, json.dumps(json.loads(text), separators=(",", ":")) does the same job. On the command line, jq -c . file.json prints the minified document. To go the other way, use Format in the editor above.

Minifying removes the spaces, tabs and line breaks that make JSON readable, so the same data takes fewer bytes. This tool does it in your browser and leaves keys, values and key order exactly as written.

Frequently Asked Questions

Does minifying change my data?

No. Only whitespace outside strings is removed. Values, key order and the contents of strings stay exactly as they were, so the result parses to the same data.

Why won't it minify my JSON?

The JSON is invalid, for example a trailing comma or a missing quote. Click Minify and the editor shows the error with its line and column; fix it and minify again.

How much smaller will it get?

It depends on how much indentation the original has. A typical document shrinks by about a quarter with tab indentation and by 40 to 60 percent with two- or four-space indentation; JSON that is already compact barely changes. If you serve JSON over HTTP, enabling gzip or Brotli saves far more.

Is my JSON uploaded?

No. Minifying runs in your browser with client-side JavaScript. The text never leaves your device.

How do I make minified JSON readable again?

Click Format in the editor. It re-indents valid JSON with two spaces per level.

Have suggestions or feedback? We're constantly improving FormatChamp based on your comments.