HTML Minifier

HTML Minifier shrinks your markup by removing comments, collapsing runs of whitespace and dropping the spaces between tags — the slack that makes HTML readable but adds bytes to every page load. The result is functionally identical markup that downloads faster.

Whitespace-sensitive regions inside pre, textarea, script and style tags are detected and left exactly as they are, so the output renders and behaves the same as the original. Minification runs entirely in your browser.

How to use HTML Minifier

  1. 1

    Paste your HTML

    Drop in a page or fragment you want to compress.

  2. 2

    Review the savings

    The original and minified sizes are shown along with the percentage saved.

  3. 3

    Copy the minified markup

    Use the copy button to grab the compact output.

What gets removed

The minifier strips HTML comments (keeping Internet Explorer conditional comments intact), collapses every run of spaces, tabs and newlines into a single space, and removes the whitespace that sits between adjacent tags. Together these account for the bulk of wasted bytes in hand-written HTML.

It deliberately preserves the content of pre, textarea, script and style elements, where whitespace is significant, so formatted code samples and inline scripts keep working exactly as written.

Why minify HTML

Smaller HTML means fewer bytes over the wire and a faster first paint, which matters most on slow connections and large pages. Minification is a standard production build step, but a quick manual pass is handy for snippets, email templates and embedded markup.

Because the transformation only removes ignorable characters, it is safe to apply to finished markup. To go the other way and make minified HTML readable again, use the HTML Beautifier.

Frequently asked questions

Will minifying break my inline scripts or styles?
No. The contents of script, style, pre and textarea tags are preserved untouched, so whitespace-sensitive code and formatting are not altered.
Does it remove IE conditional comments?
No. Standard comments are removed, but conditional comments beginning with <!--[if are kept because they affect rendering.
Is my HTML uploaded?
No. Minification runs entirely in your browser.

Last updated: