JSON Minifier
Minify JSON by removing all whitespace to shrink payload size for APIs and configs.
What gets removed
The minifier parses your JSON and writes it back with no spaces, tabs or line breaks between tokens. Spaces inside string values are left alone. The built-in sample shrinks from 49 characters to 39:
Because the output is produced from the parsed data rather than by deleting characters, it is always valid JSON. If the input isn't valid, you get an error instead of a half-minified result.
Values that are rewritten, not just compacted
Parsing and re-writing normalises a few things. The data means the same, but the text is different, which matters if you compare files or sign them:
- Numbers take their shortest form:
1.50becomes1.5,1e3becomes1000and0.1e-6becomes1e-7. - Unicode escapes are turned into the characters themselves, so
Caf\u00e9becomesCafé. - An escaped slash
\/becomes a plain/.
Duplicate keys, key order and long numbers
When a key appears twice in one object, only the last value survives. Keys that look like whole numbers are also moved to the front of the object, ahead of the others:
Integers with more than about 16 significant digits lose precision, because they are read as JavaScript numbers. {"id": 12345678901234567890} minifies to {"id":12345678901234567000}. If your payload carries IDs that long, they need to be strings for any JavaScript tool to keep them exact.
Inputs it refuses
The minifier accepts strict JSON only. Three common near-JSON habits stop it with an error:
- Comments, as found in many editor and tool config files. You'll see Invalid JSON: Expected property name or '}' in JSON at position 4 (line 2 column 3).
- A trailing comma after the last item, which gives Invalid JSON: Expected double-quoted property name in JSON at position 8 (line 1 column 9).
- Single quotes around keys or strings.
Remove these by hand and run it again. The line and column in the message point at the first character the parser couldn't accept.
Frequently asked questions
How much smaller will my file get?+
It depends on how it was indented. A file indented with spaces on every line shrinks a lot, while JSON that is already on one line barely changes. Only whitespace between tokens is saved; keys and values keep their full length.
Does it remove null values or empty arrays?+
No. Every key and value is kept, including null, empty strings, empty arrays and empty objects. Only the formatting between them is removed.
How do I make minified JSON readable again?+
Use the JSON Formatter, which parses the same way and writes the result back with indentation. Number formats and escapes normalised here will stay normalised.
Embed this tool on your website
Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.
<iframe src="https://utilityapp.lat/embed/convert/json-minifier" title="JSON Minifier" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe> <p style="font-size:13px"><a href="https://utilityapp.lat/convert/json-minifier">JSON Minifier</a> by UtilityApp</p>