JSON Minifier
Strip whitespace to produce compact JSON.
Minified 114 → 95 bytes (−16.7%)
Why Minify JSON
Minifying JSON removes all non-essential whitespace — indentation, line breaks, and spaces between tokens — producing the smallest valid representation of the same data. Smaller payloads mean faster API responses and less bandwidth. This tool parses your JSON (validating it in the process) and re-serializes it compactly, showing how much you saved. Everything runs locally in your browser.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Shrinking a config or fixture before committing it, where whitespace is pure diff noise.
- Reducing a payload before putting it in a URL, a header or an environment variable.
- Measuring how much of a response body is formatting rather than data.
- Producing a compact single line to paste into a field that rejects line breaks.
- Comparing the byte size of two payloads with formatting removed from both.
Frequently Asked Questions
- How much smaller does JSON actually get?
- Typically 10–30% for pretty-printed data, and much more for deeply nested structures where indentation dominates. But over the wire it matters far less than it looks: gzip or brotli compresses repeated whitespace almost to nothing, so the real saving is often a few percent.
- Is anything lost?
- Only whitespace outside strings. Whitespace *inside* a string is data and is preserved exactly. Key order is preserved too — JSON.parse and JSON.stringify keep insertion order for string keys, so a minified file is byte-different but semantically identical.
- Does minifying validate my JSON?
- It does, as a side effect: the text has to parse before it can be re-serialised, so a trailing comma, a single-quoted string or an unquoted key fails here. That makes it a quick syntax check as well as a size reduction.
- Should I minify a config file in my repo?
- No. A minified `package.json` or CI config is unreadable and produces useless diffs. Minify what is served or transmitted — an API payload, a data file embedded in a bundle — and leave anything a human edits formatted.
- What about very large numbers?
- Watch out: JSON has one number type and JavaScript parses it as a double, so an integer beyond 2⁵³ loses precision on the round trip — a 19-digit ID comes back changed. Transmit such values as strings; minifying cannot fix what parsing already lost.
- How much does minifying JSON actually save?
- Often 10-20% before compression and very little after, since gzip removes repeated whitespace efficiently anyway. The saving is real for uncompressed transfer and marginal over a compressed connection.
Common errors and gotchas
- Expecting comments to be preserved. JSON has none, so anything comment-like was never valid to begin with.
- Minifying and then diffing against the formatted original, which shows the whole file as changed.
- Assuming the saving matters after compression. Whitespace compresses extremely well, so the gzip delta is small.
- Removing whitespace inside string values by hand, which changes the data rather than the formatting.
- Treating a minified document as harder to read for a machine. Parsers do not care either way.
Related Formatters & Validators tools
JSON Formatter
Format, validate, and beautify JSON payloads.
Text Diff / Compare
Side-by-side or unified line/character diff comparison tool.
XML Formatter
Beautify and indent XML strings.
Minifier Suite
Minify HTML, CSS, and JS by stripping comments and whitespace.
Markdown Converter
Convert Markdown to HTML with live preview.
CSS Formatter
Beautify and indent minified or messy CSS.
HTML Formatter
Beautify and indent raw HTML markup.
SQL Formatter
Format SQL queries with keyword casing and indentation.