ToolGenie.org Logo

Free JSON Minifier Online

Minify JSON online to remove extra whitespace. Use it for API payloads, config values, and smaller request bodies. Invalid JSON is flagged with the exact error line.

Everything runs in your browser. Press Ctrl/Cmd+Enter minify.

0 characters · 0 lines · 0 bytes

How to Minify JSON Online

  1. Paste formatted JSON or upload a file.
  2. Click Minify JSON to strip extra whitespace.
  3. Copy the compact payload or download it as a .json file.

About This JSON Minifier

Minifying JSON is the opposite of formatting. This page is for compact payloads — one-line JSON for APIs, environment variables, and smaller request bodies. Beautify again with the JSON formatter, create or edit the file in the JSON editor, or check broken syntax with the JSON validator.

Minifying only removes unnecessary whitespace. Parsed values stay the same. It is not the same as gzip or Brotli compression — those shrink bytes on the wire after JSON is already compact.

How much you actually save depends entirely on how the document was written. A file indented with four spaces and one key per line can lose thirty to fifty per cent of its characters to minification, because indentation and newlines make up that much of the text. A document that was already emitted compactly by a server saves almost nothing. The saving also shrinks in relative terms as the values get longer: a payload full of long strings is mostly data, so removing the whitespace around it barely moves the total.

Minification and compression solve different problems and are best used together rather than as alternatives. Minifying removes characters from the document itself, which helps anywhere the raw text is stored or measured — an environment variable with a length limit, a database column, a URL query parameter, a webhook body with a size cap. Gzip or Brotli then compress those bytes for transport, and they are extremely good at collapsing repeated whitespace, which is why minifying a response that is already gzipped yields a much smaller win than the character count suggests. Minify when the text itself must be small; rely on transport compression when only the wire size matters.

The one real cost of minified JSON is that people cannot read it, and neither can line-based tools. A one-line file produces a useless diff — change a single character and the whole document shows as modified, so a reviewer has no way to see what you did. For that reason, keep formatted JSON in version control and minify at build time or at request time instead. Config files, test fixtures, and anything a human will open belong in the readable form.

Minification never changes the parsed value. Keys, ordering, numbers, and nesting all survive untouched, because whitespace between tokens carries no meaning in JSON. Whitespace inside a string is data and is preserved exactly — a value such as "hello world" keeps both of its spaces. That is why a minified document and its formatted original are interchangeable to any parser.

If the payload refuses to minify, it is not valid JSON. The JSON validator will point at the failing line, and the JSON formatter will expand a compact payload back into something readable when you need to inspect it again.

Frequently Asked Questions (FAQ)

How do I minify JSON online?

Paste JSON and click Minify JSON. Extra spaces and line breaks are removed, leaving a single compact payload you can copy or download.

Does minifying JSON change the data?

No. Only whitespace is removed. Parsed values, keys, and structure stay the same.

What is the difference between minify and format JSON?

Format (beautify) adds indentation and line breaks for humans. Minify strips that whitespace for machines and smaller payloads. They are opposites.

Is this JSON minifier private and safe?

Yes. Minifying runs entirely in your browser. Nothing you paste is uploaded to a server.

Is minifying JSON the same as compressing it (gzip)?

No. Minify removes JSON whitespace. Gzip or Brotli compress the bytes on the network. Use both when payload size matters: minify first, then let the server compress the response.

Why will my JSON not minify?

The syntax is invalid. Check it with the JSON validator first, fix the error line, then minify again.

How much smaller does minifying make a JSON file?

It depends on how the file was written. A document indented with four spaces and one key per line often loses thirty to fifty per cent of its characters. A payload a server already emitted compactly saves almost nothing. The more of the file is long string values rather than structure, the smaller the win.

Does minifying remove whitespace inside my strings?

No. Whitespace inside a quoted string is data and is preserved exactly, so "hello world" keeps both spaces. Only the whitespace between tokens — indentation and line breaks — is removed, because it carries no meaning in JSON.

When should I minify JSON rather than rely on gzip?

Minify when the raw text has to be small: an environment variable with a length limit, a database column, a URL query parameter, or a webhook body with a size cap. Rely on gzip or Brotli when only the wire size matters, since transport compression already collapses repeated whitespace very effectively.

Should I store minified JSON in git?

Generally no. A one-line file gives a useless diff — changing one character marks the whole document as modified, so a reviewer cannot see what changed. Keep the formatted version in version control and minify at build time or request time instead.

Does minifying JSON change key order or number precision?

Key order is preserved exactly as it arrived. Number precision is unchanged by minifying, though JSON numbers are IEEE 754 doubles, so a value with more significant digits than a double can hold was already rounded before any tool touched it. Send such values as strings if exactness matters.

Can I minify a JSON file with comments in it?

Not as strict JSON. Comments are not part of the format, so a file containing // or /* */ will fail to parse. Strip the comments first, or convert from JSON5 or JSONC into plain JSON, then minify.

Tips for Minifying JSON Safely

  • Validate first so you do not ship a broken one-liner.
  • Keep a formatted copy for humans and a minified copy for machines.
  • Watch the byte count under the editor if API payload size matters.
  • Minify at build time or request time rather than by hand. A minified file checked into git will drift out of sync with the readable one.
  • Measure the gzipped size, not just the character count. Transport compression already removes most of what minifying saves.
  • Minify config values before you paste them into an environment variable — those usually have a hard length limit and no tolerance for line breaks.
  • Expand a compact payload again with the JSON formatter whenever you need to read it, rather than squinting at the one-liner.