iPGaze

HTML Minifier

Collapse whitespace and comments in HTML.

Results appear as you type

Everything runs locally in your browser โ€” your input never leaves this page.

About the HTML Minifier

The HTML Minifier collapses redundant whitespace and removes comments from your markup to cut down its file size. Leaner HTML loads faster and uses less bandwidth, which is especially helpful for large pages and email templates. Minification happens in your browser, so your markup stays on your machine.

How to use

  1. Paste your HTML into the input area.
  2. Run the minifier to collapse whitespace and strip comments.
  3. Copy the minified HTML into your project or deployment.

Why HTML minification is riskier than CSS or JavaScript

HTML is the one of the three where whitespace can be semantically load-bearing. Inside a `<pre>` or `<textarea>`, every space and newline is content and collapsing it visibly corrupts the page. Between inline elements, a single space is rendered โ€” `<a>one</a> <a>two</a>` and `<a>one</a><a>two</a>` do not look the same. This is why an aggressive HTML minifier can break a layout in ways a CSS minifier never will.

Attribute quoting is the other place tools differ. The spec allows unquoted attribute values when they contain no spaces or special characters, so `class=btn` is valid and saves two bytes. It is also a trap: the moment a templating variable renders a value containing a space, the attribute silently truncates. Saving two bytes per attribute is not worth introducing a class of bug that only appears with certain data.

For a server-rendered application, minifying HTML is usually the least valuable of the three. Markup compresses extremely well โ€” it is highly repetitive โ€” so brotli is already doing most of the work, and unlike CSS and JS the output is regenerated on every request rather than built once. Spend the effort on the response's cache headers instead.

Frequently asked questions

What does HTML minification remove?
It removes comments and collapses unnecessary whitespace and line breaks, producing compact markup that renders identically.
Could minifying break my page?
It targets insignificant whitespace and comments, so well-formed HTML keeps rendering the same after minification.
Does my HTML leave my computer?
No. The markup is minified entirely in your browser, so nothing is uploaded.

Related Developer tools