About the HTML Minifier
The HTML Minifier shrinks HTML by stripping comments and squeezing out whitespace while leaving pre, textarea, script and style blocks untouched. Paste markup or open an .html file, compare the original, minified and gzipped sizes, and copy or download the result.
How it works
First, <pre>, <textarea>, <script> and <style> blocks are set aside untouched, because whitespace inside them matters. Then all <!-- ... --> comments are removed and every run of spaces, tabs and line breaks is collapsed to a single space.
Whitespace next to block-level tags such as <div>, <p>, <li> and <table> is removed entirely, since browsers never render it. Between inline elements like <b> and <i>, a single space is kept so words don't run together. Finally the protected blocks are put back exactly as they were, and the savings line shows the character difference.
How to use
- 1
Paste your HTML into the input box, or click Open file.
- 2
Review the minified result and the size cards.
- 3
Click Copy or Download to use the minified HTML.
Worked examples
Indented list
A formatted unordered list.
Space between inline tags is kept
Bold and italic words separated by a space.
There is nothing to remove here: the single space between the inline elements is needed, so the words still render as "bold text".
Frequently asked questions
Does minifying HTML change how the page looks?+
It shouldn't. Whitespace is only removed where browsers ignore it, spaces between inline elements are kept, and <pre> and <textarea> content is preserved. Checking the result in a browser is still good practice.
Should I minify HTML during development?+
No. Keep readable HTML while developing and minify as part of a production build or right before deployment.
Is the "bytes saved" figure exact?+
It is the difference in character count. For plain ASCII HTML that equals bytes; multi-byte characters like emoji make the real byte saving slightly different.
Will it break inline JavaScript?+
No. Inline <script> blocks are kept exactly as written, so // comments and line breaks inside them are safe.