JSON Minifier

Minified JSON—
Before (chars)—
After (chars)—
Saved (%)—

How JSON Minifier is calculated: Minified JSON = JSON.parse the input, then JSON.stringify with no indent; nothing inside strings is ever changed.

What is a JSON minifier?

A JSON minifier takes a block of JSON and strips out every character that the data does not need: spaces, newlines, and indentation. The result is the same data on a single line, as compact as it can be. Nothing about the data changes — the keys, the values, and their order all stay exactly the same.

The default text on this page shows the idea clearly. It starts as 52 characters spread over five lines, with two-space indents and spaces after every colon. Minified, it becomes 39 characters on one line: {"name":"Ada","age":36,"city":"London"}. That is 13 characters gone, a saving of 25.0% — and the data is identical.

The need comes up whenever JSON has to travel or be stored. APIs send JSON over the network, and every byte costs time. Config files and logs pile up on disk, and the whitespace in them is pure overhead. Minifying is the simplest saving available: free, instant, and completely safe when done by a real parser.

This minifier parses your JSON first and then prints it back without any spacing. That matters, because it means the output is always valid JSON — if the input is broken, it tells you so instead of handing you a mangled string. It never touches the characters inside your string values, so a space in a name or a sentence stays exactly where it was.

How minifying works

Minifying has two steps, and both are done by the parser built into your browser. First the input is parsed into a real data structure — objects, arrays, strings, numbers. If that step fails, the input is not valid JSON, and the tool reports the error instead of guessing.

Then the data structure is printed back out with no indentation at all. The printer writes each key, each value, and each comma with no spaces around them. That is the whole trick: parse, then print tight. There is no clever compression, no encoding, and nothing to undo — the output is plain JSON, just without the air.

Key order is preserved. The printer writes keys in the same order they appeared in the input, so {"name":"Ada","age":36} stays name-first. Some tools sort keys when they minify, which can break systems that read fields in order — this one does not, and that is a deliberate choice.

The size numbers tell the story. Before is the character count of what you pasted, after is the character count of the minified result, and saved is the percentage difference. On small blocks the saving looks tiny in absolute terms — 13 characters on the default — but on a real API response of a hundred kilobytes, the same percentage is a real saving on every single request.

What gets removed, and what stays

Everything outside a string is fair game. Spaces after colons, spaces after commas, newlines between lines, and indentation at the start of lines all disappear. None of them carry meaning in JSON — they exist only for human readers, and machines do not need them.

Everything inside a string stays untouched. The space in "Ada Lovelace", the newline inside a message, the spaces in a sentence — all preserved exactly. A minifier that stripped spaces from inside strings would corrupt the data, and this one never does. The test for it is simple: minify {"b": "x y"} and the space between x and y is still there.

Numbers are printed in their shortest form. The parser reads 36.0 as the number 36 and prints 36; it reads 1.50 as 1.5. The value is the same, but the printed form is shorter. The same goes for true, false, and null — they print exactly as themselves, because there is nothing shorter to print.

One thing minifying does not do is shorten your keys. A key called "customerShippingAddress" stays that long. If keys are eating your bandwidth, the fix is shorter key names in your data design, not a minifier. Minifying removes the air between values; it never renames anything.

A worked example: shrinking an API payload

Take the default block: five lines, 52 characters, nicely indented for reading. Minified, it is one line of 39 characters. The saving is 13 characters, or 25.0%. That is a quarter of the size gone, and the data is byte-for-byte the same in meaning.

Now try a block that is already minified: {"a":{"b":[1,2,3]},"c":true}. It starts at 28 characters and stays at 28 characters, with 0% saved. That is the correct answer — there was nothing to remove. A minifier that claims to shrink already-minified JSON is lying, and this one reports the honest zero.

Try a block with a space inside a string: {"a": [1, 2, 3], "b": "x y"} spread over three lines. Minified, it becomes {"a":[1,2,3],"b":"x y"} — 34 characters down to 23, a saving of 32.4%. The spaces around the numbers are gone, but the space inside "x y" is still there. That is the rule working as it should.

Finally, try broken input: {"a":1,}. The tool does not minify it — it reports invalid JSON with the error at character 7, the closing brace after the trailing comma. Minifying broken JSON would only produce broken JSON faster, so the tool refuses and points at the problem instead.

Who minifies JSON, and why

API developers are the biggest users. A server that answers a million requests a day pays for every byte it sends, in bandwidth and in time. Minified responses are smaller, faster, and cheaper — and the client parses them exactly the same way. Most production APIs minify by default, and this tool matches what they produce.

Front-end developers are the second group. Config files, mock data, and test fixtures are written pretty for humans and shipped minified for machines. Minifying by hand is a waste of time and a source of mistakes; pasting the block here and copying the result takes two seconds and cannot introduce an error.

Data workers are a third group. Log files and exports pile up fast, and the whitespace in them is dead weight. Minifying a large export before storing or sending it can cut a quarter of its size, which matters when the file is tens of megabytes and the connection is slow.

Students are a fourth group. Minifying is the fastest way to see what JSON actually is once the layout is stripped away: keys, values, commas, braces — nothing else. It teaches the difference between the data and the decoration, which is the first thing anyone working with JSON needs to learn.

JSON minifier vs JSON formatter

A minifier and a formatter are exact opposites, and both are useful. A JSON formatter takes tight JSON and spreads it out with two-space indents so a human can read it. A minifier takes spread-out JSON and squeezes it tight so a machine can move it. Same data, two layouts, two jobs.

The workflow is a loop: format to read, minify to ship. You write config pretty so you can edit it, then minify it before it goes to the server. You receive a minified API response, format it to read it, fix what is wrong, and minify it again before sending it back. The two tools sit on either side of that loop.

Size is a separate question from layout. A data storage converter tells you what 100 KB means in megabytes, and a word counter tells you how big a block is — but neither one changes the text. The minifier is the tool that actually makes the block smaller.

Moving JSON safely is another job again. A base64 encoder decoder turns JSON into a single safe string for transport inside a URL or a header. Base64 makes the text longer, not shorter — so minify first, then encode. The order matters: shrink the data, then wrap it for the journey.

Common minifying mistakes

The most common mistake is minifying with a text search-and-replace instead of a parser. Removing all spaces from JSON by hand also removes the spaces inside strings, which corrupts names, sentences, and addresses. Always minify with a real parser — one that knows which spaces are decoration and which are data.

Second: minifying and then editing the result by hand. Minified JSON is meant to be read by machines, not people. If you need to change a value, go back to the pretty version, edit that, and minify again. Editing a single-line block by hand is how commas get lost and brackets get mismatched.

Third: assuming minified JSON is compressed. It is not. Minifying removes whitespace, which is usually a quarter of the size, but real compression — the kind a web server does — shrinks the rest. Minifying and compression work together: minify first, then let the server compress what is left.

Fourth: minifying JSON that is already broken and expecting the tool to fix it. A minifier cannot repair a missing quote or a trailing comma. If the tool reports invalid JSON, fix the error it points to and minify again. The error message is the help, not the obstacle.

How to use this JSON minifier

Using this JSON minifier is simple. Paste your JSON into the box, or type it directly. The minified result appears instantly in the box below, with the before and after character counts and the percentage saved shown above it. There is no button to press and no form to submit.

To use the result, select the text in the output box and copy it. To minify another block, select all, delete, and paste the new one — the counts reset instantly. If the JSON is invalid, the output box shows the error message instead; read it, fix the spot it points to, and paste again.

Everything runs in your browser. No sign-up, no account, no data sent anywhere — your JSON never leaves your device. It works offline once the page has loaded, so you can use it on a plane, in a server room with no signal, or anywhere else you work with data.

Try it with something real before you need it: paste a pretty-printed API response and watch a quarter of its size disappear. Once you have used it twice, you will never ship pretty JSON to a server again — and you will never minify by hand either.

Frequently Asked Questions

No. Minifying only removes whitespace outside strings — spaces, newlines, and indentation. The keys, values, and their order stay exactly the same, and the minified block parses to the identical data. The one exception is number formatting: 36.0 prints as 36, which is the same number written shorter.

It depends on how pretty the input was. The default block on this page goes from 52 characters to 39, a saving of 25.0%. Deeply indented blocks with long lines can shrink by 30% or more, while already-minified JSON shrinks by 0% — there is nothing left to remove. As a rough guide, expect a quarter of the size to disappear.

Never. A minifier built on a real parser knows which spaces are decoration and which are data. The space in "Ada Lovelace" or in a sentence stays exactly where it was. Only the spaces between keys, values, and brackets are removed. If a tool strips spaces from inside your strings, it is broken — do not use it.

No. Minifying starts by parsing the JSON, and if the parse fails the tool reports the error instead of producing output. For example, {"a":1,} is rejected with the error at character 7, the closing brace after the trailing comma. Fix the error the message points to, then minify again.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.