Free HTML Minifier
Minify HTML to shrink page size and improve load speed. This minifier removes HTML comments, collapses inter-tag whitespace, and trims attribute whitespace โ while safely preserving everything inside <pre>, <code>, and <textarea>, plus optional IE conditional comments. Smaller HTML means faster first paint, lower bandwidth, and better Core Web Vitals scores.
Why minify HTML?
Every byte matters for real users: on mobile networks, a 40% HTML reduction can shave hundreds of milliseconds off critical rendering. Minified HTML also makes your markup cleaner to ship through build pipelines. Unlike JS/CSS, HTML minification is best done at build time โ use this tool to prepare templates, email HTML, or static pages before deployment.
HTML Minifier FAQ
Is minified HTML still valid? Yes โ whitespace between markup tags is insignificant to rendering, so removing it doesn't change output (except inside pre/code/textarea, which we preserve). What happens to inline JS and CSS? Their content is preserved verbatim and only surrounding whitespace is trimmed. Can I undo minification? Yes โ use our formatter/beautifier to re-indent the compact markup (or keep a copy of the original). Is my code sent anywhere? No โ everything runs locally in your browser.