/tools/json-minifier

JSON Minifier

Minifying removes every space and newline a parser does not need. Useful before sending JSON over the wire, storing it in a column, or embedding it in a data attribute.

JSON MinifierRuns in your browser

How to use the JSON Minifier

  1. Paste formatted JSON into the input box.
  2. Press Minify. The document is parsed first, so invalid JSON is rejected rather than silently mangled.
  3. Check the saving, then copy the compact output or download it as a file.

How much minifying actually saves

The saving depends entirely on how deeply nested your document is, because indentation is what gets removed. A flat object with ten keys saves very little. A deeply nested configuration file indented with four spaces can shrink by 30–50%.

Before optimising for these bytes, check whether your transport already compresses. Gzip and Brotli handle repeated whitespace extremely well — often the difference between a minified and formatted document after compression is under 5%. Minifying matters most where compression is not available: database columns, localStorage, URL parameters and HTML data attributes.

What minifying does not do

This is whitespace removal, not compression. It will not shorten your keys, drop null values, deduplicate repeated strings or change your structure. If you need a genuinely smaller payload, the wins come from schema design — shorter key names, arrays of values instead of arrays of objects — not from formatting.

Because the document is parsed and re-serialised, numeric values are normalised the same way as in the formatter: 2.0 becomes 2, and 1e2 becomes 100.

Frequently asked questions

Will minified JSON still parse everywhere?

Yes. Whitespace between tokens is optional in the JSON specification, so every conforming parser reads the minified form identically.

Is this the same as compressing?

No. Compression algorithms like gzip re-encode the data; minifying only deletes whitespace characters. You can do both, and the order does not matter.

Can I get my formatting back?

Yes — run the output through the JSON Formatter. Since only whitespace was removed, nothing is lost. Original indentation choices are not recoverable, but the data is identical.

Does it remove comments?

It rejects them. Comments are not valid JSON, so the document fails to parse before minifying begins.

Related tools