JSON Minifier
Paste JSON to strip every unneeded space and line break. The minifier validates as it goes, points to the exact line and column of any error and never rounds your numbers.
How to use the JSON Minifier
- Paste your JSON into the left box, or upload / drop a .json file.
- Pick options: sort keys, accept comments and trailing commas (JSONC) or escape non-ASCII characters.
- Press Minify JSON (the output also updates as you type).
- Fix any error: the message shows the line and column and a caret marks the exact character.
- Copy or download the minified JSON and check the bytes saved.
What JSON minification removes
JSON (RFC 8259) allows four whitespace characters between tokens: space, tab, line feed and carriage return. A minifier deletes all of them outside strings and changes nothing else. Whitespace inside a string value is data and is always kept.
| Input | Minified | Note |
|---|---|---|
{ "a" : 1 , "b" : [ 1, 2 ] } | {"a":1,"b":[1,2]} | Spaces around : , [ ] { } removed |
{"msg": "hello world"} | {"msg":"hello world"} | Spaces inside strings are kept |
{"id": 12345678901234567890} | {"id":12345678901234567890} | Numbers copied exactly, no rounding |
{"x": 1.50, "y": 1e3} | {"x":1.50,"y":1e3} | Number spelling is preserved |
{"b": 1, "a": 2} + Sort keys | {"a":2,"b":1} | Keys ordered, arrays untouched |
{"a": 1, // note"b": [2,],} + JSONC | {"a":1,"b":[2]} | Comments and trailing commas stripped |
Common JSON errors and how to fix them
| Error message | Typical cause | Fix |
|---|---|---|
| Unexpected “]”: trailing commas are not allowed | [1, 2,] | Delete the last comma, or enable JSONC |
| Expected a property name in double quotes | {name: "x"} or {'name': "x"} | Quote keys with " |
| Expected “,” or “}” after a property value | Missing comma between two properties | Add a comma at the caret |
| Unescaped control character in string | A real line break or tab inside a string | Write \n or \t instead |
| Numbers cannot have leading zeros | {"zip": 01234} | Use a string: "01234" |
| “True” / “None” / “NaN” is not valid JSON | Python or JavaScript literals pasted as JSON | Use true, false, null or a number |
How the size saving is calculated
Sizes are counted in UTF-8 bytes, the encoding used on the web. Saved % = (original bytes − minified bytes) ÷ original bytes × 100. For example, the 276-byte sample in the tool minifies to 219 bytes, a saving of 57 bytes or 20.7%.
The gzip figure is produced with your browser's built-in CompressionStream. Servers usually compress JSON responses with gzip or Brotli, so minifying and compressing together gives the smallest transfer. Minification still helps: it reduces memory use, storage and the work the compressor has to do, and it makes cache keys and hashes stable when combined with key sorting.
Frequently asked questions
What does a JSON minifier do?
It removes all whitespace that sits outside strings: spaces, tabs and line breaks used for indentation. The data stays exactly the same, so any JSON parser reads the minified file identically, but it is smaller to store and send.
Will minifying change my numbers or strings?
No. This tool uses its own parser that copies every number and string exactly as you wrote it, so large integers such as 12345678901234567890 and escapes such as \u00e9 are kept. Many online tools use JSON.parse, which rounds numbers above 2^53.
How do I find a JSON syntax error?
The minifier validates while you type. If the JSON is invalid it shows the line and column, explains what was expected and draws a caret under the offending character. Common causes are trailing commas, single quotes and missing commas between items.
What does Sort keys do?
It orders the keys of every object alphabetically, recursively, comparing UTF-16 code units like the JSON Canonicalization Scheme. Sorted, minified JSON is handy for diffs, hashing and caching. Array order is never changed.
Can it handle comments and trailing commas?
Yes. Tick “Allow comments & trailing commas (JSONC)” and the tool accepts // and /* */ comments plus trailing commas, as used in tsconfig.json or VS Code settings, and outputs strict JSON.
How much smaller does JSON get?
Pretty-printed JSON with two-space indentation usually shrinks by 15–40%. The gzip figure shows what the file would weigh when served with compression, which is what matters over the network.
Is my JSON uploaded anywhere?
No. Parsing, minifying and the gzip estimate all run inside your browser. Nothing you paste or upload leaves your device.