JSON Minifier — Compact JSON Online
JSON Minifier
Paste JSON and get it back on one line with the spaces, indentation and line breaks removed. The minifier runs JSON.stringify(JSON.parse(input)): it parses the text with the browser's JSON.parse and writes the value back with no whitespace. The code runs in your browser and makes no network request with the input.
How this tool handles JSON
- Whitespace outside string values is removed, including spaces, tabs and newlines. Spaces inside strings are kept. The output has no trailing newline.
- Values are re-written, not copied. Numbers take their JavaScript form:
1.0becomes1,1e3becomes1000,-0becomes0, and1.50becomes1.5. - Escapes are normalized.
\/becomes/, and\u00e9becomesé. Other non-ASCII characters are written as they are. - Duplicate keys keep the last value.
{"a":1,"a":2}minifies to{"a":2}with no warning. The Validate command does report duplicates. - Invalid input returns a message that begins with a red cross mark and the text
Invalid Json:, followed by the parser's error and its position. Empty input is an error too. - Auto-correct runs before you minify when the input is not valid. It removes
//and/* */comments and trailing commas, accepts single quotes and unquoted keys, and strips a byte-order mark.
Worked example
A pretty-printed user record, 187 bytes in UTF-8:
{
"user": {
"id": 12345,
"name": "Alex",
"roles": ["admin", "editor"]
},
"active": true,
"metadata": {
"lastLogin": "2025-11-28T09:00:00Z",
"notes": null
}
}Minify produces this 137-byte output:
{"user":{"id":12345,"name":"Alex","roles":["admin","editor"]},"active":true,"metadata":{"lastLogin":"2025-11-28T09:00:00Z","notes":null}}Gotchas
Comments are not removed by Minify. The input {"a":1 /* note */} returns an error at line 1, column 8. Run Auto-correct first. It returns {"a":1}, and then Minify can run.
Numbers can change. {"a":1.0,"e":123456789012345678901234567890} minifies to {"a":1,"e":1.2345678901234568e+29}. Integers above 2^53 lose precision. Keep long IDs as strings.
A byte-order mark breaks parsing. A file that begins with a BOM fails with Unexpected token. Auto-correct removes the BOM.
NaN and Infinity are not JSON. {"a":Infinity} is rejected. Auto-correct turns NaN into the string "NaN", so check the result before you ship it.
Duplicate keys are silent here. Minify keeps the last value and says nothing. Run Validate first when the source file is hand-edited.
Frequently asked questions
Does minifying change the data?
The structure, strings, booleans and null stay the same. Numbers are re-written, so 1.0 becomes 1 and integers above 2^53 lose precision.
Is minified output still valid JSON?
Yes, when the input was valid. The output is produced by JSON.stringify, so it parses back to the same value.
Can I minify a file that has comments?
Run Auto-correct first. It removes // and /* */ comments. Then run Minify on the result.
Will a very large file freeze the page?
The minifier does not use Web Workers or streaming. The parse runs on the main thread, so a very large input can make the page unresponsive until it finishes. For large files, jq -c . file.json produces the same compact output from the command line.
Can I get pretty JSON back? Yes. Run Format, which offers indents of 2, 3, 4 or 8 spaces.