How to Minify JSON (and When It Actually Helps)

Updated · 4 min read · MetaSol Technologies

Minifying JSON removes every character that is not needed: spaces, tabs and line breaks between tokens. The result is one dense line that parsers read exactly like the original.

How to minify

  1. Open the JSON Minifier.
  2. Paste or upload your JSON.
  3. Press Minify. The status line shows the size before and after.

Whitespace inside strings is part of the data and is never touched.

How much does it save?

For typical formatted JSON with 2-space indentation, minification saves around 15–30%. The deeper the nesting, the more indentation there is to remove.

Compression is a different story. Text compression is very good at removing repetitive whitespace:

Version Example size
Formatted (2 spaces) 100 KB
Minified 76 KB
Formatted + gzip 14 KB
Minified + gzip 12 KB

(Illustrative figures for a typical API response; your data will differ.)

If your server already sends responses compressed with gzip or Brotli, minifying adds only a small further saving.

When minifying is worth it

  • JSON embedded in HTML (for example <script type="application/ld+json">), where it is not compressed separately.
  • Storage: databases, caches and queues that store JSON without compression.
  • Query strings and headers, where every byte counts and line breaks are not allowed.
  • Fixtures and snapshots that you want on a single line.

When to keep it formatted

  • Files kept in version control. One item per line produces readable diffs.
  • Config edited by people.
  • Debug logs that someone will read.

Minify plus sort

Combining minification with Sort keys produces a canonical form: the same data always becomes the same string. That is useful for hashing, caching keys and detecting duplicates.