JSON Minifier Online
Compress and minify JSON by removing all whitespace and formatting.
When a JSON minifier is the right tool
Pretty-printed JSON is easy to read and expensive to paste into a log, a query string, or a small fixture. This page is for the compact form: paste JSON, click Minify, and copy a single-line document with the whitespace removed. Character counts are shown for the input and the output, plus a savings percentage when the result is shorter.
It is a parse-and-stringify, not a text squeeze. Invalid JSON is rejected. If you also want a beautified copy in a live editor, use the JSON Formatter.
Use cases
Compacting a config or an API example
Load Sample pastes a short package-like object with nested author and dependencies fields. After Minify you get one line you can drop into a test or a request body.
Seeing how much space the pretty-printing used
The input header shows the current length as you type. After a successful minify, the output header shows the new length and, when the compact form is shorter, a green savings badge.
Checking that a document is valid JSON
A failed parse shows the JavaScript error message and no output. Fix the input and click Minify again. Comments and trailing commas will not pass.
How minification works
Minify calls JSON.parse, then JSON.stringify without a spacer. The output block is hidden until that succeeds. Changing the input clears the output, so the savings figure always compares the current input to the last successful compact string.
{
"name": "diffcheck",
"version": "1.0.0"
}
{"name":"diffcheck","version":"1.0.0"}Spaces, line breaks, and indentation are gone. The values are unchanged. A string that already contained spaces is left as it was, because the squeeze only removes JSON whitespace between tokens.
What this tool does not do
It does not minify as you type, beautify, or accept JSON with comments. Nothing is sent to a server. To indent the same document, use the JSON Formatter.
How to use JSON Minifier
- Paste your JSON, or use Load Sample for a short example.
- Click Minify.
- Copy the compact output when it appears, or Clear to start over. After you edit the input, minify again.
Frequently asked questions
Is minification live as I type?
No. You click Minify to run it. The output pane appears only after a successful run. Editing the input, or using Load Sample, clears the previous output and any error, so you need to minify again after a change.
What does Minify actually do?
It parses the input with JSON.parse and writes it with JSON.stringify, with no extra spaces or indentation. Comments and trailing commas are rejected, because they are not valid JSON. Duplicate keys follow ordinary JSON.parse rules (the last value wins). Key order is otherwise kept.
How is the savings percentage calculated?
It is the rounded change in JavaScript string length: (1 - output.length / input.length), shown only when that value is greater than zero. It is not a UTF-8 byte count. If you minify text that is already compact, the badge may not appear and the output can even be slightly longer in unusual cases (for example when the input was shorter than the canonical stringify form).
How is this different from Minify on the JSON Formatter page?
Both parse and re-serialize JSON. This page is dedicated to the compact form: it is not live, it shows character counts and a savings badge, and it hides the output until you click Minify. The JSON Formatter can also beautify, stays in a two-pane layout, and updates as you type.
Is my JSON sent to a server?
No. Parsing and stringifying run in your browser when you click Minify. Closing the tab discards what you pasted. Do not paste documents that contain secrets if you would not be comfortable with them sitting in memory on this device.
Is there a file size limit?
There is no server-imposed limit, because nothing is uploaded. Typical config files are comfortable. A very large document can make the tab feel slow; in that case, minify a smaller excerpt or use a local tool.
Related tools and guides
References
- RFC 8259 is the JSON format this page accepts. Comments and trailing commas will fail JSON.parse.