HTML minifier
Strip comments and formatting whitespace to shrink HTML. Runs entirely in your browser.
Runs 100% in your browserHow to minify HTML
- Paste your HTML. Paste the markup you want to shrink.
- Minify. Comments and formatting whitespace are stripped instantly.
- Copy or download. Grab the minified HTML.
About HTML minification
HTML authored for humans is full of indentation and comments that browsers don't need. Removing them trims bytes off every page load. This minifier takes a careful approach — it strips comments and collapses formatting whitespace but preserves the contents of pre-formatted and code blocks and keeps meaningful spacing between inline elements — so the rendered result matches your source. For the inline CSS and JavaScript, run the CSS and JS minifiers.
Frequently asked questions
- It removes HTML comments and collapses the formatting whitespace (indentation and line breaks) between and inside elements, while preserving the contents of
<pre>,<textarea>,<script>and<style>so code and pre-formatted text are untouched. - It is deliberately conservative: it keeps authored single spaces between inline elements and never touches protected blocks, so rendering is preserved. It does not minify the JavaScript or CSS inside the page — use the JS and CSS minifiers for those.
- Yes. Legacy IE conditional comments (
<!--[if …]>) are preserved; ordinary comments are removed. - No. Everything runs in your browser.