JSON Minifier
Remove whitespace from JSON to reduce its size.
What is JSON Minifier
JSON minification removes line breaks and whitespace from JSON to reduce data size, commonly used to cut transfer overhead.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
Removing whitespace without touching strings
Whitespace outside string literals is insignificant in JSON, so it can be dropped entirely. The subtle part is that whitespace inside strings is data: "hello world" must keep both spaces. A minifier that runs a regex over the raw text breaks such values, and the damage only shows up later when a field no longer matches.
This implementation tokenises properly — strings and escapes are tracked — so only structural whitespace is removed. The output is byte-different and semantically identical, which is what makes it safe to minify as a build step.
What minifying does not buy you
With gzip or brotli in front of it, minified JSON is typically only a few percent smaller on the wire, because the compressor already removes the repeated spaces. The real benefit is on parse time and on payloads that travel without compression — a webhook body, a Redis value, an embedded config.
Minifying also destroys readability, diffs and review. Keep the formatted source in version control and minify at build or at send time; minified JSON committed to a repository makes every future change unreviewable.
The failure that looks like success
If the input is not valid JSON, a tolerant minifier can still produce output that looks plausible while having removed something it should have kept — inside a broken string, whitespace is ambiguous. Always parse the result before shipping it: a one-line JSON.parse check catches the whole class of problem.
Copy-paste damage is the usual cause here too. A curly quote or a non-breaking space pasted from a document is not structural whitespace in the JSON sense, and depending on the tokeniser it either survives into the output or breaks the value. Escaping it explicitly is the reliable fix.
How to use it
- 1.Paste your JSON
- 2.Click Minify
- 3.Copy the result
How JSON Minifier works under the hood
Formatters parse your input into a structure, then serialise it back with consistent indentation. That is why a formatter can also reveal a syntax error: if it cannot parse, it cannot print.
- 1
Parse into a tree
JSON goes through JSON.parse; YAML, XML, CSS and SQL use their own parsers. The parse either succeeds with a structure or fails at a line and column.
- 2
Serialise with a fixed style
Indentation width, key order and quoting are applied deterministically, so formatting the same input twice gives identical bytes.
- 3
Show the error position
When parsing fails, the message includes the position so the fix is obvious instead of guessed.
Processing pipeline
Formatting is not validation
A formatter proves the document is syntactically parseable. It does not prove it is valid against a schema, and it does not check business rules. JSON with a duplicated key parses fine and silently keeps the last value.
What gets normalised
Comments are preserved in CSS and SQL but not in JSON, which has no comment syntax. YAML anchors may be expanded, and quote style may change. Keep the original when exact byte layout matters, such as signed payloads.
Verify it yourself
Formatting is deterministic and local — run it twice and compare.
- 1.Open DevTools on this page and switch to the Network tab
- 2.Keep the filter on Fetch/XHR and run the tool
- 3.Confirm no request carries your file — you should see only page assets and fonts
Frequently asked questions
What is JSON minification?
It removes whitespace to shrink the file size.
Does the data change?
No. Only cosmetic whitespace is removed; the data stays identical.
What this kind of conversion cannot keep
Formatters parse the input into a tree and print it back with consistent indentation. If the input is invalid, you get the parser's error position instead of a silently mangled file — malformed JSON stays malformed rather than being «repaired» into something that is no longer yours.
More in Format
On this page
- What is JSON Minifier
- What this tool actually does with your file
- How it actually behaves
- How to use it
- How it works inside
- Frequently asked questions
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →