Hand written and template generated HTML carries a lot of bytes that a browser does not need: indentation, blank lines, developer comments and quotes around attribute values that never needed them. This minifier removes that padding and shows you the original size, the minified size and the percentage saved. The contents of pre, textarea, script and style blocks are pulled out and put back afterwards, so whitespace sensitive text and inline code survive the process unchanged.
Two options are off by default because they change the markup rather than just the spacing. Removing quotes around simple attribute values is valid HTML5 but only when the value has no spaces, quotes, equals signs or angle brackets, which is checked before each attribute is rewritten. Collapsing boolean attributes turns disabled="disabled" into disabled. Downlevel conditional comments are recognised and kept. Remember that gzip or brotli on your server usually saves more than minification does, and the two stack.
How to use the HTML Minifier
- Paste your HTML page or fragment into the input box.
- Choose the options you want: comment removal, whitespace between tags, attribute unquoting and boolean attribute collapsing.
- Click Minify HTML and check the size and percentage saved in the stats row.
- Click Copy and paste the minified markup into your file, keeping the original source for future edits.
Frequently asked questions
Will minifying break my page layout?
It can if your layout relies on the whitespace between inline elements. Browsers render the gap between two adjacent links or spans as a real space, so removing it closes them up. If you see elements touching after minifying, untick Remove whitespace between tags and run it again.
Are script and style blocks minified too?
No. Their contents are protected before minifying and restored afterwards, because collapsing whitespace inside JavaScript or CSS with an HTML parser is unsafe. Use a dedicated CSS or JavaScript minifier for those, then paste the result back into your page.
Is minification the same as obfuscation?
No. Minification only removes bytes that carry no meaning for the browser. The markup stays fully readable to anyone who runs it through a formatter, and view source still shows your structure. It is a transfer size optimisation, not a way to hide anything.
Should I minify if my server already uses gzip?
Compression usually saves far more than minification, because gzip and brotli handle repeated whitespace and tag names very efficiently. Minifying first still helps a little since there is less input to compress, but treat it as a small extra gain rather than the main win.