HTML minifier

Minify and improve the performance of HTML code.

  • Development
  • 100% free
  • No sign-up
  • Runs in your browser
HTML minifier

What is the html minifier?

The HTML minifier removes comments and collapses whitespace in your HTML, trims the spaces around block level tags and minifies the CSS of inline style tags. The content of pre, textarea and script elements is preserved exactly.

Lighter HTML reaches the browser faster, especially on mobile networks, and helps the first contentful paint. Minification is also a good last step for email templates and static pages.

How to use the html minifier

  1. 1Paste your HTML code.
  2. 2Press Minify to compress it.
  3. 3Copy the minified HTML.

Features

Comment removal

HTML comments are removed, conditional comments are kept.

Whitespace collapse

Runs of spaces and line breaks are reduced.

Inline CSS

Style tags are minified with the CSS minifier.

Safe blocks

pre, textarea and script contents are left untouched.

Frequently asked questions

Can minifying HTML change the layout?

Spaces between inline elements are kept as a single space, so the layout stays the same.

Is HTML minification worth it?

The savings are smaller than for CSS and JS once gzip is on, but they still add up on large pages.

Are scripts minified too?

Inline scripts are kept as they are. Use the JS minifier for JavaScript.

Is my code uploaded?

No, everything is processed in your browser.