JSON Minifier
Paste JSON to compress it to a single line with no extra whitespace. The footer shows the new size and exactly how many bytes you saved. One of our free JSON tools.
Input
Output
How to minify JSON
- Step 1
Paste or open the JSON
Paste it, drop a file, or load a URL. Minify is already selected.
- Step 2
Check the saving
The output footer shows the new size and how many bytes and what percentage you saved.
- Step 3
Copy or download
Copy the single-line JSON or download minified.json.
Worked example
{
"flags": {
"dark_mode": {
"enabled": true,
"segments": []
}
},
"version": 42
} {"flags":{"dark_mode":{"enabled":true,"segments":[]}},"version":42}
132 B → 67 B · saved 65 B (49%) What minifying removes
JSON allows spaces, tabs and line breaks between any two tokens, and none of them carry meaning. Minifying removes all of them: the indentation, the line breaks, and the space after each colon and comma. Whitespace inside strings is part of the data and is never touched, so "New York" keeps its space. Key order is preserved, and parsing the minified text gives exactly the same value as the original.
How much you save
The saving depends on how the file was formatted. Pretty-printed JSON with a 2-space indent usually shrinks by 15 to 35 percent; 4-space or tab indentation and deep nesting save more, as the example shows. JSON that is mostly long strings saves little, because there is little whitespace to remove. The figures in the footer compare UTF-8 bytes, which is what counts for storage, request bodies and size limits, so a character like é counts as two bytes on both sides.
Minify or gzip?
If you serve JSON over HTTP with gzip or Brotli, compression already removes most of the cost of whitespace on the wire, and minifying first makes only a small further difference. Minifying still pays off wherever the text is stored or handled uncompressed: in databases and caches, in browser localStorage with its roughly 5 MB limit, in log lines, in environment variables and Kubernetes secrets, and when you embed JSON in HTML or a JavaScript bundle.
Stable output with sorted keys
Tick Sort keys to order every object's keys alphabetically before minifying. Two documents with the same data then produce byte-for-byte identical output, which is what you want when the JSON is used as a cache key, hashed for an ETag, or signed.
Comments and precision
JSONC files with comments and trailing commas can be minified too: tick Allow comments (JSONC) and the comments are dropped along with the whitespace, leaving strict JSON. One thing to watch: numbers are read as 64-bit floating point, so integers longer than 15 or 16 digits can lose precision. Keep such IDs as strings. To go back the other way, use the JSON formatter; to embed the minified JSON inside another string, use JSON Escape.
Questions and answers
Does minifying change my data?
No. Only whitespace between tokens is removed. Strings, including any spaces inside them, keys, numbers and the order of keys stay as they were. Parsing the minified output gives exactly the same value.
How is the saving calculated?
It compares the UTF-8 size of your input with the size of the minified output, in bytes, and shows the difference as a number and a percentage of the input.
Can I minify JSON that has comments?
Yes. Tick Allow comments (JSONC) and the comments and trailing commas are dropped, which also turns a JSONC config into strict JSON.
Is there any point minifying if my server uses gzip?
Compression removes most of the cost of whitespace on the wire, but minified JSON is still smaller in memory, in storage, in browser localStorage, in log lines and anywhere the payload is not compressed, such as environment variables.
Is minified JSON still valid JSON?
Yes. Whitespace between tokens is optional in JSON, so the minified version is just as valid and any parser reads it the same way.
Related tools
All JSON & Schema toolsNext step
Need this built into your stack?
The team behind SyntaxSnap builds custom code generators, internal developer tools and API integrations.