HTML Minifier
Compress and minify HTML code instantly. Reduce file sizes, remove comments, and optimize your web pages for faster loading explicitly in your browser.
About the HTML Minifier
Paste an HTML document or fragment and get a smaller version with comments and extra whitespace removed, while spaces that matter between words are kept.
Everything you enter is processed in your browser; nothing is uploaded or stored.
How to use it
- Paste your markup into Input Raw HTML.
- Leave “Remove HTML comments” ticked unless you need them (for example conditional comments).
- Copy the minified result, or press Clear All to start again.
How HTML minification works
The minifier removes <!-- comments --> when the option is on, then collapses newlines, tabs and runs of spaces. Whitespace between tags is reduced so that inline text still reads correctly.
HTML is often the first file a browser downloads, so trimming it shortens the time before rendering starts, especially on slow mobile connections.
Example
<ul> <li>One</li> <!-- todo --> <li>Two</li> </ul> becomes <ul><li>One</li><li>Two</li></ul>.
Tips
- Content inside <pre> and <textarea> depends on whitespace; check those parts after minifying.
- Templates with server tags (PHP, Jinja, Liquid) should be minified after rendering, not before.
Frequently asked questions
Is minified HTML bad for SEO?
No. Search engines read minified HTML exactly like formatted HTML; the text, links and tags are unchanged.
Should I remove HTML comments?
Usually yes for production. Keep them only if a script or old IE conditional comment depends on them.
Does it minify inline CSS and JavaScript too?
It collapses their whitespace with the rest of the page; for a full minification use the CSS and JavaScript minifiers.