HTML Minifier

Compress HTML markup by collapsing whitespace and comments.

What Does the HTML Minifier Do?

The HTML Minifier shrinks web pages by collapsing runs of whitespace, removing the gaps between tags and stripping HTML comments. Content that must keep its exact formatting — everything inside <pre>, <textarea>, <script> and <style> blocks — is automatically protected and passes through unchanged, so your code samples and inline scripts keep working.

Conditional comments for legacy Internet Explorer (<!--[if IE]>) are also preserved, while ordinary comments are removed. The result renders identically but downloads faster, typically saving 10–25% of file size.

How to Minify HTML

  1. Paste your markup into the left box.
  2. Choose whether to remove comments and/or collapse whitespace (both on by default).
  3. Click Minify HTML and check the size report.
  4. Copy the result or download it as page.min.html.

Why Minify HTML?

  • Faster first paint — HTML is the first thing the browser downloads; a smaller document means parsing starts sooner and improves LCP.
  • Email size limits — Gmail clips messages over 102 KB; minifying an HTML email template can keep it under the limit.
  • Landing pages and templates — hand-built pages without a build pipeline still deserve production-grade output.
  • Bandwidth at scale — a few KB saved per page adds up across thousands of daily visitors.

Frequently Asked Questions

Will minification break my inline JavaScript or CSS?

No. Everything between <script>…</script> and <style>…</style> is protected and copied through byte-for-byte, along with <pre> and <textarea> content.

Can collapsing whitespace change how a page looks?

In rare cases the space between two inline elements is visually significant; collapsing "> <" to "><" can remove it. If you notice missing spaces between inline links or buttons, keep whitespace collapsing off for that page.

Why are IE conditional comments kept?

Comments like <!--[if lt IE 9]> are functional markup for legacy browsers, not documentation — removing them would change behavior, so the minifier leaves them alone.

How much smaller will my HTML get?

Typically 10–25%, depending on indentation depth and comment volume. Heavily indented template output compresses the most; the exact numbers are shown after each run.