← All free tools Developer tools

HTML minifier

Minify your HTML by removing all the unnecessary characters.

About this tool

The HTML minifier makes HTML smaller by removing what browsers don’t need: comments and the extra spaces, tabs and line breaks used to make code readable. It shows how much it saved, in percent and bytes.

How to use the HTML minifier

  1. Paste your HTML: a whole page or a snippet.
  2. Press Minify.
  3. Copy the minified HTML.

What it changes, and what it leaves alone

  • Removes comments, except conditional comments for old Internet Explorer.
  • Collapses runs of whitespace into a single space, and removes it around block elements like div, p and li, where it never shows.
  • Keeps the content of pre and textarea exactly as written, since whitespace matters there.
  • Leaves inline script and style blocks untouched, so it can’t break your JavaScript or CSS. Minify those separately with the JS and CSS minifiers.

It’s deliberately careful: spaces between inline elements, such as two links in a sentence, are kept as one space, so the page looks exactly the same.

Is it worth it?

Minified HTML usually saves 5 to 20%. Servers that compress pages with gzip or Brotli already shrink whitespace well, so the bigger wins are often images and scripts. Minifying still helps for HTML in emails, for embedded widgets, and on hosts that don’t compress. Keep the readable original for editing.

Have a project in mind?

Have a brand or a product to grow?