HTML Minifier
Minify HTML by removing comments and white space, optionally minifying inline CSS and JavaScript. Shows the size saved. Free, in your browser.
About HTML Minifier
The HTML Minifier makes pages smaller by removing comments and extra white space, and can also minify inline CSS and JavaScript. It shows how many bytes you saved.
Five switches
Five switches control what is removed, such as comments and white space, and whether inline CSS and JavaScript are minified too.
Test before you publish
Minifying scripts or removing attribute quotes can break some pages. Check the result in a browser before it goes live.
No repairs
Broken HTML is not fixed or reported.
Good for
Shrinking a static page, an email template or a landing page by hand, without a build tool.
Private
Everything runs in your browser. Nothing you paste is uploaded.
How to use HTML Minifier
- Paste your HTML or open a file.
- Tick the options you want.
- Read the minified result and the size saved.
- Copy it or download a .html file.
Related guide: Speed Up Your Website: Minify CSS, JavaScript and HTML
Help & FAQ
What does the HTML Minifier do?
It removes comments and unnecessary white space from HTML and can also minify inline CSS and JavaScript.
Which options are on by default?
Remove comments, Minify inline style and Tidy class/style whitespace are on. Minify inline script and Remove quotes are off.
Does it keep spaces in pre blocks?
Yes. In the test the pre block kept its leading spaces and line break.
Does it keep IE conditional comments?
Yes. The comment option says it keeps IE conditional comments while removing normal comments.
What does Minify inline script do?
It runs Terser on script blocks. In the test var total = 1 + 2 became var total=3.
What does Remove quotes around simple attribute values do?
It writes id="x" as id=x. Values with spaces, such as class="a b", keep their quotes.
Does it fix broken HTML?
No. An unclosed tag was left as it was, with no error message.
Is the inline CSS fully minified?
Not fully. In the test the space before the colon was left, giving color :red.
How much does it save?
A 275 B sample dropped to 223 B, 19 percent. The saving depends on comments, indentation and inline code.
Can minifying change how our page looks?
Rarely, but removing white space between inline elements can. Check the page after minifying.
Is there an example?
Yes. Press Load example for a sample page.
Is our HTML uploaded?
No. It is minified in your browser.