Output appears here.
The JSON Minifier removes every unnecessary space and line break from JSON, producing a compact single line and showing how many bytes you saved. Use it for request bodies, environment variables, fixtures and anything with a size limit. It validates the input as it goes. Minification runs in your browser; nothing is uploaded.
How to minify JSON
- Paste formatted JSON, drop a
.jsonfile, or press ⌘/Ctrl O. The compact version appears immediately. - Turn on Sort keys for a canonical, diff-stable line, or Allow comments & trailing commas if the source is a JSONC config file.
- Copy the single line with ⌥/Alt C or download it with ⌘/Ctrl S. To embed it inside another string, use Escape as string; to read it again, use Format.
Examples
Formatted object
A pretty-printed object compacts to one line. The status line reports "130 B → 96 B" and "26% smaller". Note that 1.50 is kept exactly as written.
{
"id": 1042,
"status": "active",
"user": {
"name": "Asha Rao",
"roles": ["admin", "editor"]
},
"price": 1.50
}Result:
{"id":1042,"status":"active","user":{"name":"Asha Rao","roles":["admin","editor"]},"price":1.50}Sorted keys
The same input with Sort keys on. Two payloads with the same content produce the same line, whatever order their keys arrived in.
{
"id": 1042,
"status": "active",
"user": {
"name": "Asha Rao",
"roles": ["admin", "editor"]
},
"price": 1.50
}Result:
{"id":1042,"price":1.50,"status":"active","user":{"name":"Asha Rao","roles":["admin","editor"]}}Config with comments (lenient)
With Allow comments & trailing commas on, the comment and the trailing comma are removed along with the whitespace ("Removed 1 comment and 1 trailing comma.").
{
// service name
"name": "api",
"port": 8080,
}Result:
{"name":"api","port":8080}Options explained
- Sort keys — orders object keys alphabetically at every depth before compacting, so equivalent objects minify to identical strings.
- Allow comments & trailing commas — accepts JSONC/JSON5-style input by stripping
//and/* */comments and trailing commas; without it, they are reported as errors.
Common minification errors
Minifying requires valid JSON, so the minifier reports the same errors as the JSON Validator, with a line, column and likely cause.
"JSON does not allow comments"
The input contains // or /* */. Turn on Allow comments & trailing commas, and the comments are dropped from the minified output.
Trailing comma after the last item
A comma before ] or } is not valid JSON. Remove it, or turn on the lenient option.
"This looks like a JavaScript object, not JSON"
Unquoted keys and single quotes mean the input is a JavaScript object literal. Convert the quotes, or use the automatic fix in the JSON Validator.
Several documents pasted together
Two JSON values one after another — common when copying from a log with one object per line — cannot be combined into a single minified value. Minify them one at a time, or wrap them in [ and ] with commas between them.
FAQ
Is it safe to minify payloads with tokens or keys in them?
Yes. The minifier runs in your browser inside an isolated frame that blocks network requests, so API keys, JWTs and customer records in the JSON never leave your device, and nothing is stored on a server. Settings are remembered on this device; the input is only kept if you turn on "Remember my last input".
Does minifying change any values?
No. Only whitespace between tokens is removed. Strings keep their contents, including spaces and escapes such as \\ and \n; numbers are copied character for character, so 1.50 and very long integers are unchanged. Key order changes only when Sort keys is on.
How much smaller will my JSON get?
It depends on how it was indented. Pretty-printed JSON with 2-space indentation typically shrinks by a quarter to a half; deeply nested files with 4-space indentation save more. The status line shows the exact sizes before and after, and the percentage saved.
Is minifying the same as compressing?
No. Minifying removes characters that carry no meaning, and the result is still readable JSON. Compression such as gzip or Brotli encodes the bytes and must be decoded before use. They work well together: web servers usually compress responses, and minified JSON compresses slightly smaller still.
How do I put minified JSON in an environment variable or a string?
Minify it first, then use Escape as string, which opens JSON Escape / Unescape. It adds the backslashes needed to place the JSON inside a JSON or JavaScript string literal. Many shells also need the whole value wrapped in single quotes.
Can I get the formatted version back?
Yes. Use the Format action, or paste the line into the JSON Formatter. Because minification only removes whitespace, formatting restores a readable layout; comments removed in lenient mode cannot be recovered.
When to minify JSON
Minify when the JSON is read by machines: request bodies, message queues, cache entries, query parameters, single-line log fields and test fixtures compared as strings. Keep formatted JSON in version control and documentation, where people read and diff it. Script bundles need a different approach — the JavaScript Minifier also shortens names and removes dead code — and the remaining JSON tools are listed under data tools.