Skip to main content
KalkuNet

HTML Minifier — Remove White Space and Comments Without Changing the Look

Compress HTML documents by removing redundant whitespace & HTML comments.

Runs in your browserDeveloper · Formatters, Minifiers & Code Builders

527 → 485 bytes (8% smaller).

  • The content of <pre>, <textarea>, <script> and <style> is left alone (except the CSS option). White space is removed only where browsers do not show it, such as between block tags; spaces between words and inline elements stay.
  • The gzip size is measured by your browser and is close to what a server sends with gzip compression.

When to use the HTML Whitespace & Comment Minifier

  • Only white space that is not shown

    Spaces between block tags and at block edges go, runs of spaces in text become one, and spaces between words or inline elements stay, so the page looks the same.

  • Comments removed, conditional comments kept

    Ordinary comments are removed because they are never shown. IE conditional comments such as <!--[if IE]> are kept because old browsers still read them. Turn the option off when comments must stay.

  • CSS inside style minified too

    With the option on, the content of <style> is minified with the same CSS minifier. The content of pre, textarea and script is never touched because spaces there can matter.

  • Bytes and gzip saved

    The size before and after, the percentage saved and the gzip size measured by your browser show at once. The output is tested with html5lib to make sure the document stays the same.

Frequently asked questions

What saving is typical?

Hand-written pages usually shrink 10–25%; after gzip the difference is smaller because gzip also compresses spaces.

Is the output safe for templates?

Template syntax such as {{ name }} or <?php ?> is read as plain text and is not changed, but check the result again if your template relies on particular spaces or line breaks.

Are attributes or quotes removed?

No. Only the spaces between attributes are tidied; values and their quotes stay.

What about JavaScript in the page?

The content of <script> is left as it is. Use a separate JavaScript minifier if needed.

Is my code uploaded?

No. Minifying and the gzip measurement run in your browser.

Learn more