HTML Minifier

Paste HTML to remove comments and squeeze the whitespace between tags, producing a smaller page that renders the same. The contents of pre, textarea, script and style are left intact. Everything runs in your browser.

Paste HTML, then press Minify HTML.

What minifying removes

HTML browsers treat any run of whitespace between tags as a single space, so the line breaks and indentation that make source readable add bytes without changing the page. Minifying removes HTML comments and collapses that inter-tag whitespace to produce a smaller, faster-loading document.

saved % = (original − minified) ÷ original × 100

The minifier strips <!-- ... --> comments, collapses multiple spaces to one and removes whitespace directly between adjacent tags - all changes a browser cannot see in the rendered output.

Worked example

An indented block collapses to a single line:

Before: a <div> with comments, line breaks and four-space indents.
After: <div class="box"><h1>Hello</h1><p>A short paragraph.</p></div>
Saving: typically 15-40% on hand-written, well-indented HTML.

What it protects

Some whitespace is significant: text inside <pre> and <textarea> renders literally, and the code inside <script> and <style> can break if spacing changes. The minifier detects those regions and leaves them untouched, collapsing whitespace only where it is safe. Everything runs locally, so your markup never leaves the browser.

Tip: minifying the assets too? Use the CSS minifier and the JS minifier.

Frequently asked questions

Does minifying change how the page looks?

No. Only comments and whitespace that the browser already ignores are removed, so the rendered page is identical - it just downloads a little faster.

Is the content of pre and textarea safe?

Yes. Whitespace inside pre and textarea is significant and rendered literally, so the minifier detects those elements and leaves their contents exactly as written.

What about script and style?

Their contents are preserved as-is, because collapsing whitespace inside JavaScript or CSS could change behaviour. To shrink those, use the dedicated JS and CSS minifiers.

Is my HTML uploaded?

No. The minifier runs in your browser with string processing. Nothing you paste is sent to a server.

MB
Mustafa Bilgic · Editor, Calcool
Collapses inter-tag whitespace and removes comments while protecting the contents of pre, textarea, script and style. Everything runs in your browser - nothing you enter is uploaded, logged or stored.

Related calculators