How to Minify JSON (and When You Should)

Minifying JSON removes every unnecessary character — spaces, newlines, indentation — leaving the smallest valid representation. It's the opposite of formatting.

What minification does

Formatted JSON is built for humans:

{
  "name": "app",
  "tags": ["web", "api"]
}

Minified, it's built for the wire:

{"name":"app","tags":["web","api"]}

Identical data, fewer bytes. No information is lost — only whitespace.

How much do you save?

For typical config and API payloads, minification cuts 15–30% of raw size, mostly from indentation and newlines. The deeper the nesting, the bigger the win.

When to minify

  • API responses — every byte counts at scale, and clients don't read them by eye.
  • Embedded JSON in HTML or query strings.
  • localStorage / cookies where size limits are tight.

When not to bother

  • Config files humans edit — keep them formatted.
  • When you already gzip. HTTP compression removes most of the redundancy minification targets, so the marginal gain on top of gzip is small.

Minify vs gzip

They're complementary. Minification removes whitespace at the text level; gzip compresses the byte stream. Production APIs often do both. For source files you commit, neither is necessary.

One caution

Never hand-edit minified JSON — a single misplaced comma is nearly impossible to spot on one line. Always format first, edit, then minify as the last step. Validate with the validator before stripping whitespace.

Got a config file to check?

Open the config toolkit →