How to get an accurate result from the HTML Minifier
An accurate result from the HTML Minifier comes from two habits: pasting the exact original you mean, and checking the byte counts before you copy the answer. The tool already uses exact rules, so most accuracy problems come from pasting a copy that was already changed, or from copying the answer without looking at what was removed. The checks below take a minute and catch every common slip.
At a glance
Paste the original, not a copy that was already minified
The most common accuracy slip is pasting in a file that was already minified somewhere else and then wondering why the saving is small. The sample output, at 64 bytes, pasted back in comes out at 64 bytes again, with 0 saved, because there is nothing left to remove. Always start from the original file, the one with its line breaks, indentation and comments still in it. If the percentage reads 0%, check whether the input was already minified before you blame the tool.
Check the three lines before you copy
Read the three lines under the big percentage. The first line gives the two sizes, Original and Minified, the second gives the bytes saved, and the third says what was done. For the sample those lines should read Original: 91 characters, Minified: 64 characters, and Saved: 27 characters, with 30% smaller above them. If the original size is not what you expected, the wrong file went in, or a piece of it was left behind when you copied. Paste again, and check that the first line matches the size of the file you meant to minify.
Confirm the percentage by hand
The percentage is (original − minified) ÷ original × 100, rounded to a whole number. For the sample that is 27 ÷ 91 × 100, which is 29.7%, shown as 30%. For the typical small page it is 93 ÷ 291 × 100, which is 32.0%, shown as 32%. If you work the sum out and it does not match the big line, the two sizes on the first line are the numbers to trust, because the percentage is worked out from them. A one-point difference is just rounding; a bigger difference means the input changed between pastes.
Check that nothing you need was changed
Accuracy is not only about the size. Open the minified output and check three things. First, the words: a sentence should still have one space between its words, so <p>Hello world, this is a test.</p> should read <p>Hello world, this is a test.</p>, from 49 bytes to 35. Second, the attributes: class="card" should still read class="card", and a link to /about/ should still point to /about/. Third, anything where spaces matter: a pre block, a textarea, or a script string containing <!--, because the tool collapses whitespace everywhere and removes anything between comment markers.
Same input, same output, every time
The tool is deterministic: paste the same HTML twice and you get the same answer twice. The sample always gives 91, 64 and 27, and the small page always gives 291, 198 and 93. That makes the sample a useful anchor: paste it in first, and if it gives 91, 64 and 27, the tool is working as expected, and any difference in your own page comes from your page, not from the tool. If the anchor ever gives a different answer, the sample itself has changed, and that is the thing to fix.
The common mistake
People copy the minified output from the box and paste it straight into their site without opening it once. The output is almost always right, but the one time it is not, it is usually a pre block or a comment between two words, and opening the page in a browser would have shown it in seconds. Paste the sample, check the three lines, open the result, and only then put it live.
Frequently asked questions
How do I know my minified result is accurate?
Check the three lines: Original, Minified and Saved. For the sample they should read 91, 64 and 27 characters, with 30% smaller above them.
Why does my page only save 0%?
Because the input was already minified. The 64-byte sample output pasted back in comes out at 64 bytes again, with 0 saved.
How is the percentage saved worked out?
As (original − minified) ÷ original × 100, rounded to a whole number. For the sample that is 29.7%, shown as 30%.
What should I check in the minified output?
That sentences still have single spaces, that attributes such as class="card" are unchanged, and that no pre block, textarea or script string was damaged.
More guides on the HTML Minifier
- How to use the HTML Minifier — step by step
- HTML Minifier explained with worked examples
- HTML Minifier formula — how it actually works
- HTML Minifier for beginners — start here
- Common mistakes people make with the HTML Minifier
- HTML Minifier vs doing it by hand — which is faster?
- HTML Minifier — The Complete Guide
- HTML Minifier for students — with examples
- HTML Minifier for homeowners and DIYers
Try the HTML Minifier — free, in your browser.