How to use the HTML Minifier — step by step
An HTML file is mostly words and tags, but it also carries weight you never see: line breaks, indentation, and comments left over from building the page. The HTML Minifier strips that dead weight out and leaves the page itself alone. Open it and it is already working, because a sample page is loaded for you. The five steps below take you from that sample to your own minified page, and the whole job takes less than a minute.
At a glance
Step 1: open the tool and look at the sample
The sample is a small card: a div with a heading that reads Hello and a paragraph that reads Welcome to WhiteUI, plus a comment that says a note. As written it is 91 bytes. The result panel already shows 30% smaller in big type, and underneath it three lines read Original: 91 characters, Minified: 64 characters, and Saved: 27 characters.
Step 2: paste your own HTML
Click into the Your HTML box, select the sample, and paste your page in its place. The tool minifies as you type, so there is no button to press and no waiting for a result. A typical small page with a heading, a paragraph and a list is 291 bytes as written and comes out at 198 bytes, with 93 bytes saved, or 32% smaller. The count updates with every keystroke, so you can watch the saved number change as you paste.
Step 3: read the three lines
The big line tells you the percentage saved. Under it, the first line gives the two sizes, Original and Minified, the second line gives the bytes saved, and the third line says what was done: comments removed, whitespace between tags collapsed. The percentage is worked out as (original − minified) ÷ original × 100. For the sample that is 27 ÷ 91 × 100, which is 29.7%, shown rounded as 30%. If the percentage reads 0%, your HTML was already tight, and there was nothing left to remove.
Step 4: copy or download
When the numbers look right, press Copy minified HTML to put the result on your clipboard, then paste it where your page lives. Or press Download .html to save it as a file called minified.html. Either way, what you copy is the finished page: the same tags and the same words, with the dead weight taken out.
Step 5: check the result before you use it
Open the minified page in a browser and look at it. Headings, paragraphs and lists should read exactly as before, because the words keep their single spaces. Then check anything where spaces matter: a pre block, a textarea, or a script that contains the characters <!--. This minifier collapses whitespace everywhere, including inside those blocks, so a page that relies on exact spacing needs a careful look before you publish the minified version.
Worked example
Take the sample and follow it through. The original is 91 bytes. The 27 bytes that disappear are easy to account for: the comment is 15 characters, the four line breaks are 4, the indentation before the tags is 6 spaces, and the two spaces around the word Hello are 2. That adds up to 27, which is exactly what the tool reports. The minified page reads <div class="card"><h2>Hello</h2><p>Welcome to WhiteUI.</p></div>, and it is 64 bytes. Nothing else changed: the class name, the words and the tags are all exactly as they were.
The common mistake
People paste the minified output back into the tool and expect it to shrink again. It does not. The 64-byte output pasted back in comes out at 64 bytes, with 0 saved, because there is nothing left to remove: no comments, no line breaks, no doubled spaces. Minifying twice gives the same answer as minifying once. If the percentage reads 0%, the job is done, and pasting it in again will not find more.
Frequently asked questions
What does the HTML Minifier show when it opens?
A sample card page of 91 bytes, already minified to 64 bytes: 30% smaller, with 27 bytes saved.
How do I minify my own HTML?
Click into the Your HTML box, select the sample, and paste your page in. It minifies as you type, with no button to press.
How is the percentage saved worked out?
As (original − minified) ÷ original × 100. For the sample that is 27 ÷ 91 × 100, which is 29.7%, shown rounded as 30%.
How do I save the minified HTML?
Press Copy minified HTML to put it on your clipboard, or Download .html to save it as a file called minified.html.
More guides on the HTML Minifier
- 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
- How to get an accurate result from the HTML Minifier
- HTML Minifier for students — with examples
- HTML Minifier for homeowners and DIYers
Try the HTML Minifier — free, in your browser.