HTML Minifier

HTML Minifier

Shrink HTML by removing comments and collapsing whitespace. You control both options.

The HTML Minifier reduces the size of a web page's markup by removing the parts written for humans: comments and generous whitespace. Smaller HTML downloads faster, which helps visitors on slow connections and can trim real costs on busy sites. The size report shows the exact bytes before and after, measured on your actual input.

You stay in control with two clear options. Remove Comments strips ordinary HTML comments while always protecting conditional comments that old browsers rely on. Collapse Whitespace squeezes the gaps between tags and repeated spaces into the minimum the markup needs.

Honesty matters here: this minifier works on the markup itself. It does not rewrite, rename, or optimise the JavaScript and CSS inside your page beyond the whitespace options you select, and it never removes needed spaces inside text or attribute values. For deep build-pipeline minification, dedicated build tools go further; for a quick, safe shrink of a page or template, this tool is the right size. Everything runs in your browser with no upload.

How to use

  1. Tick or untick the comment and whitespace options.
  2. Paste your HTML into the box.
  3. Click Minify HTML.
  4. Check the byte saving in the status line.
  5. Copy the minified result into your file or template.

Frequently asked questions

Will minified HTML still work the same?

In normal cases, yes: browsers ignore the comments and extra whitespace being removed. Pages using preformatted blocks or whitespace-sensitive layouts should be checked after minifying, like any change.

What are conditional comments and why are they kept?

They are special comments some legacy browsers read as instructions. Deleting them could change behaviour on those browsers, so this tool always preserves them.

Does it minify my JavaScript and CSS too?

It does not rewrite inline scripts or styles semantically. Whitespace collapsing may trim gaps around them, but renaming, bundling, and dead-code removal need a build tool.

Is my code uploaded?

No. All processing is local in your browser.