HTML Minifier

Shrink HTML by removing comments and collapsing whitespace.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Minify HTML in your browser

Paste any markup to remove comments and collapse whitespace between and inside tags, producing a smaller file that downloads faster. It is handy for trimming the page weight of static pages, email templates, and embedded snippets.

How it works

The minifier strips standard HTML comments (<!-- ... -->) while keeping IE conditional comments that legacy pages may still rely on, then collapses runs of whitespace between and inside tags down to a single space or removes them. Crucially it leaves the contents of pre, textarea, script and style exactly as written, because spaces, tabs and newlines are meaningful in those elements. The result is functionally identical markup with the bulk of the layout whitespace gone, and the tool reports how many characters you saved.

Example

This formatted input:

<!-- nav -->
<ul>
  <li>Home</li>
  <li>About</li>
</ul>

minifies to:

<ul><li>Home</li><li>About</li></ul>

The comment and the indentation are gone, but the elements and their text are unchanged. Everything runs locally in your browser — nothing is uploaded.

Ad placeholder (rectangle)