HTML Minifier

Online HTML Minifier

This tool strips HTML comments and collapses whitespace between tags to reduce page weight, while leaving the contents of <pre>, <textarea>, <script>, and <style> blocks untouched, since whitespace inside those is often meaningful.

Features:

  • Comment removal: Strips <!-- ... --> HTML comments.
  • Whitespace collapsing: Removes blank lines and extra spacing between tags.
  • Preserves sensitive blocks: Content inside <pre>, <textarea>, <script>, and <style> is left exactly as written.
  • Client-side only: Your markup never leaves your browser.

1. Why Minify HTML

HTML minification rarely saves as much as JS or CSS minification, but on a text-heavy page with lots of nested markup and indentation, the savings add up — and every byte counts for a page's Largest Contentful Paint on a slow connection.

2. What Gets Left Alone

Whitespace inside <pre> and <textarea> is part of the displayed content, so collapsing it would visibly change the page. Script and style blocks are skipped too, since collapsing whitespace inside CSS or JS is a different problem — use the dedicated JS Minifier for embedded scripts.

Will minifying break my page layout? No, as long as your CSS doesn't rely on whitespace between inline elements for spacing (a rare, usually unintentional dependency). Content inside pre, textarea, and script/style blocks is left untouched.
Does this remove HTML comments used by templating systems? Yes, all standard HTML comments are stripped. If your build pipeline relies on comments as template markers, minify after that step runs, not before.
Should I minify HTML in development? No. Keep readable, commented HTML while developing and minify only the production output — minified HTML is much harder to debug in browser dev tools.

Need readable HTML back? Use the HTML Formatter.

100% client-side — your markup is never uploaded.

Related Tools