JSON Minifier

Minify JSON to its smallest valid form and see exactly how many bytes the whitespace was costing.

106Input characters
76Output characters
28.3%Saved

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the JSON Minifier does

This JSON minifier will minify JSON to its smallest valid form and see exactly how many bytes the whitespace was costing. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for shrinking a JSON payload before storing or embedding it. The companion to this one is our MIME type lookup.

How to use it

  1. Paste the JSON.
  2. Turn on key sorting if you intend to compare two documents.
  3. Read the size saving in the stats.
  4. Copy the minified output.

How it works

Minifying JSON removes insignificant whitespace between tokens. On a formatted document it typically saves 20 to 40% of the characters, and the saving is larger the more deeply nested the structure.

Over HTTP that saving mostly evaporates, because gzip and brotli compress repeated whitespace almost to nothing — the compressed size difference between formatted and minified JSON is usually a few percent, not forty. Minifying is still worth doing for data stored at rest or sent without compression.

Key order is not significant in JSON by specification, so sorting keys does not change the meaning. It does make two documents diffable, which is the main reason to do it.

When to use it

  • Shrinking a JSON payload before storing or embedding it.
  • Normalising two documents so they can be diffed.
  • Checking a document is valid JSON before using it.
  • Collapsing a formatted response into a single line for a log.

Common mistakes to avoid

  • Minifying a config file a human has to maintain.
  • Expecting minification to help much over a gzip-compressed connection.
  • Assuming sorted keys will survive a round trip through a system that reorders them.

Frequently asked questions

Does minifying JSON change its meaning?

No. Whitespace between tokens is insignificant in JSON, and key order is not part of the data model. The parsed result is identical.

How much does minifying save?

Typically 20 to 40% of the raw characters on formatted JSON. Over a gzip-compressed connection the real-world saving is far smaller.

Why sort the keys?

To make two documents comparable. Key order is not significant, so sorting lets a diff show only genuine differences.

Related tools

See all developer tools →