JSON minifier
Strip whitespace to shrink JSON for the wire.
Paste a JSON document and the minified version appears alongside it, with the byte savings shown at the bottom. Typical reduction on a hand-indented document is 20–60%. The output is what JSON.stringify(value) with no indent argument would give you.
What minifying actually does
The minifier calls JSON.parse on what you pasted, then re-serializes withJSON.stringify and no indent argument. That's the one-liner; anything else you read about JSON minification is variations on that pattern. The output is byte-identical to what your backend would produce by default.
Nothing inside string values is touched — a space inside "hello world" stays as it is. Numbers are normalised to their shortest round-trippable form, so 1.0 may come out as1, but the parsed value is unchanged.
How much you actually save
The headline figure of "20–60% smaller" depends entirely on how the source was written. Here is a worked example of the same five-record dataset at three indentation styles:
- Two-space indented: 412 bytes → 188 bytes minified (54% reduction)
- Four-space indented: 562 bytes → 188 bytes (67% reduction)
- Already single-line, but with spaces after colons and commas: 224 bytes → 188 bytes (16% reduction)
The smaller the keys and the deeper the nesting, the more dramatic the absolute saving. A 1 MB JSON file that was hand-formatted with four-space indents commonly minifies to under 400 KB.
Minification vs. gzip — when each matters
The most common pushback on minification is that gzip already removes repeated whitespace very efficiently. That is true. A response that goes from 1 MB to 400 KB minified will only shrink to roughly 90 KB once gzipped — and the pretty-printed version gzips to maybe 95 KB. The marginal wire saving is small.
Where minification still wins:
- No compression on the link. Internal service-to-service calls, message queues, and many gRPC-over-JSON setups don't bother with gzip because CPU is more expensive than bandwidth at small payload sizes. Here the minified bytes are exactly what's transferred.
- Storage and logs. A document database, S3 bucket, or log aggregator that stores raw JSON text pays for every byte. Minified JSON compresses better at rest too, because there is less redundant whitespace for the compression dictionary to handle.
- Memory and parse time. A 1 MB string is faster to parse than a 2.5 MB string even though the parsed value is identical. The cost is small per request but compounds when a service handles thousands per second.
- Embedded JSON. When JSON is a value inside another JSON document (a webhook payload, a configuration field, a database column), every extra byte of indentation in the inner document gets escaped and re-encoded in the outer document, multiplying the cost.
Worked example
Input (89 bytes including indentation):
{
"user": {
"name": "Ada",
"skills": ["math", "computing"]
}
}Minified output (50 bytes):
{"user":{"name":"Ada","skills":["math","computing"]}}That is a 44% reduction with no information loss. Pasting the minified version back into a JSON formatter will reproduce the original document exactly (give or take which indent size you choose).
When you should not minify
- Anything a human will read. Configuration files, fixture data in source control, and error responses in development are easier to debug pretty-printed. Reserve minification for the wire.
- Git-tracked files. Minified JSON produces enormous, unreviewable diffs. Keep the indented version in the repo; minify at build time if you ship the file to a CDN.
- Snippets in documentation. A minified example in a README defeats the purpose of the example.
Common errors and how to fix them
- "Unexpected token" at the start of the document. The minifier validates as it goes — if it rejects your input, the document is not valid JSON. Run our JSON validator first to find the exact line and column.
- Output is the same size as the input. Your input is already minified, or contains mostly string content (long descriptions, base64 blobs) where there is no whitespace to remove.
- Numbers look different after minifying.
1.0becomes1,1e2becomes100, and very long decimals may be re-rendered in scientific notation. The numeric value is unchanged — only the textual form. - Comments disappeared. JSON does not support comments, and the minifier (correctly) won't accept them either. If you have comments in your source, you have JSON5 or JSONC, not JSON. Strip them with a JSONC-aware preprocessor before minifying.
How JSONNeat's minifier works under the hood
The minifier calls the browser's native JSON.parse on your input, then immediatelyJSON.stringifys the result with no second or third argument. This is the same approach used by virtually every production JSON minifier — the spec-compliant parsers are the same code that runs in V8, SpiderMonkey and JavaScriptCore, so the output is byte-identical to what your Node.js or browser backend would produce. Nothing exotic, no regex hackery, no whitespace-stripping heuristics that could break edge cases.
Privacy
The minifier runs entirely client-side. Your JSON is never uploaded, logged or cached on JSONNeat's servers. That makes it safe for minifying internal configuration files, JWT payloads, or anything else you would not want to paste into a third-party tool that touches a remote backend.
Frequently asked questions
- Why minify JSON?
- Minified JSON removes every byte of whitespace that is not inside a string value. Smaller payloads mean faster network transfer, lower bandwidth bills, less memory pressure on servers and clients, and reduced compression overhead when responses are gzipped.
- How much smaller is minified JSON?
- Typically 20–60% smaller depending on how much indentation the source used. A document indented with four spaces and one key per line can shrink by more than half. The relative savings shrink for documents that are mostly long strings (because string contents are not touched), and grow for deeply nested structures with short keys.
- Will minifying break my JSON?
- No. Whitespace outside string values has no semantic meaning in JSON, so minifying is fully reversible — running the output through any JSON formatter restores readable indentation. The parsed JavaScript value is identical before and after.
- Does gzip already do this? Should I bother?
- Gzip and Brotli will compress repeated whitespace very efficiently, so the wire savings from also minifying are smaller than the raw byte count suggests — often only 5–15% additional reduction. But compression is not always on: between microservices on the same host, in queues, when writing to disk, or in databases that store JSON as text. In those cases minification gives you the full saving.
- Will minifying remove duplicate keys or change ordering?
- No. JSONNeat parses your input and re-serializes it, which preserves the order in which keys appear and keeps all values intact. If the input had duplicate keys, JavaScript's JSON.parse keeps the last occurrence — this is the standard behaviour and not specific to minification.
- Can I minify newline-delimited JSON (NDJSON)?
- Not in one shot — NDJSON is multiple JSON documents separated by newlines, not a single JSON value. Minify each line individually, or join the lines into an array first.
- Does minification affect floating point precision?
- No. Re-serializing a parsed number produces the shortest string that round-trips to the same IEEE 754 double. You may see "1.0" become "1" or "1.2000000000000002" become "1.2000000000000002" — the actual stored value is unchanged.
- What about Unicode escapes like \u00e9?
- JSONNeat's minifier emits the most compact valid representation, which usually means leaving non-ASCII characters as-is (UTF-8) rather than as \u escape sequences. The parsed value is identical either way. If you need pure ASCII output, post-process with a Unicode escaper.
- Will the minifier handle very large files?
- Yes — anything you can fit in browser memory, typically a few hundred megabytes. Beyond that, use a streaming minifier like jq -c, which processes input in chunks instead of loading the whole document.
- Is this safe for sensitive payloads?
- Yes. Minification happens entirely in your browser using local JavaScript — JSONNeat never sees the data. The same guarantee applies whether you are minifying a public schema or a JWT token from a private API.