← All blog posts

How to get an accurate result from the JSON Minifier

WhiteUI · A plain-English guide to the JSON Minifier

An accurate result from the JSON Minifier comes from two habits: pasting the exact text you mean to minify, and checking the byte counts the tool reports before you copy the result. The tool already uses exact arithmetic, so most accuracy problems come from retyping a file by hand, which can change a value, or from counting characters instead of bytes, which gives a different number when the file holds a rupee sign.

At a glance

Rupee price: 9 of 45 bytes savedSaved 9 bytesKept 36 bytes45 → 36 bytes · 20.0% smaller
Minifying a file with a price in rupees saves 9 of 45 bytes: the result is 36 bytes, which is 20.0 percent smaller.

Paste the exact text, do not retype it

If your file lives in an editor or a settings page, copy it from there and paste it into the tool. Retyping it by hand can change a value without you noticing: a price of 149.50 typed as 149.05 is a different number, and a name typed with one letter wrong is a different name. The tool minifies exactly what you paste, so a retyped file gives an exact minification of the wrong data. Copy and paste takes the same few seconds, and it removes the risk entirely.

Check the byte counts before you copy

Read all three numbers in the result panel after every paste: original size, minified size, and bytes saved. For the default example they should read 22 bytes, 13 bytes, and 9 bytes saved. For the small profile they should read 81 bytes, 64 bytes, and 17 bytes saved. If any number looks wrong, the text you pasted is not the file you meant to minify, and fixing the input is quicker than correcting the output afterwards. The big line at the top is the saving; the two smaller lines underneath are the sizes it came from.

Count bytes, not characters

The tool counts bytes in UTF-8, which is how a file is actually stored, and that is not the same as counting characters when the file holds a rupee sign. The rupee sign costs 3 bytes, so the string "₹500" is 8 bytes in total: one byte for each quote, three for the rupee sign, and one each for the three digits. A small file holding an item, notebook, and a price, "₹500", is 45 bytes and minifies to 36 bytes, saving 9 bytes, or 20.0 percent. For plain English text the two counts match, because each English letter is one byte, but for a rupee sign they do not, and the byte count is the number that decides whether a file fits a limit.

Check the numbers in the result

Numbers come out written in their shortest form, and that is part of the saving, not a mistake. A price written as 149.50 becomes 149.5, and a total written as 597.00 becomes 597, because 149.50 and 149.5 are the same value, and so are 597.00 and 597. A nested order shows this: it goes from 282 bytes to 175 bytes, saving 107 bytes, and some of those are the zeroes dropped from the two prices. If a number in your result looks shorter than the number you typed, compare the values, not the writing: the value is unchanged.

Worked check: the default example

Check any answer against the anchor: the default example is 22 bytes, and the minified result is 13 bytes, saving 9 bytes, or 40.9 percent. Paste it in, and if the big line does not read 9 bytes, the text you pasted is not the default example. Then try the profile: 81 bytes in, 64 bytes out, 17 bytes saved. Two checks, under a minute, and you know the tool is reading your files exactly as they are.

The common mistake

People compare the tool’s byte count with the character count shown by their editor, and think the tool is wrong when the two disagree. They disagree because they measure different things: the editor counts characters, the tool counts UTF-8 bytes. For a file with a rupee sign, the byte count is always higher, because the sign costs 3 bytes for one character. Trust the tool’s number when a size limit is involved, because size limits are measured in bytes, not characters.

Frequently asked questions

How do I get an exact result from the JSON Minifier?

Paste the exact text from your editor instead of retyping it, then check the original size, the minified size and the bytes saved before you copy the result.

Why is the byte count higher than my editor’s character count?

The tool counts UTF-8 bytes, and the rupee sign costs 3 bytes for one character. For plain English text the two counts match, but for a rupee sign they do not.

What should the default example minify to?

From 22 bytes to 13 bytes, saving 9 bytes, or 40.9 percent. If the big line does not read 9 bytes, the text pasted in is not the default example.

Why did 597.00 become 597 in my minified JSON?

The tool writes numbers in their shortest form. 597.00 and 597 are the same value, and the shorter writing is part of the saving.

More guides on the JSON Minifier

Try it yourself

Try the JSON Minifier — free, in your browser.

Open the JSON Minifier