HTML Minifier

Free online HTML minifier — remove comments and collapse whitespace to shrink HTML, while preserving pre, script and style blocks. Runs locally.

Runs entirely in your browser — nothing you enter is uploaded or stored.

Ask about this tool on

Shrink HTML without breaking it

This dependency-free minifier strips comments and collapses redundant whitespace to make your markup smaller and faster to transfer, while carefully protecting the parts of a page where whitespace matters.

What is protected

  • The raw contents of <pre>, <textarea>, <script> and <style> are left byte-for-byte unchanged.
  • IE conditional comments <!--[if …]> are kept.
  • The size readout shows original vs minified bytes and how much you saved.

Frequently asked questions

What exactly gets removed?

Ordinary HTML comments, runs of whitespace collapsed to a single space, and whitespace sitting between tags. The visible content of your page is preserved.

Will it break my <pre> or <script> blocks?

No. The contents of <pre>, <textarea>, <script> and <style> are pulled out before minifying and restored untouched afterwards, so formatting and code inside them survive exactly as written.

Are conditional comments kept?

Yes. Internet Explorer conditional comments such as <!--[if lt IE 9]> are preserved because removing them would change how the page renders. Only plain comments are stripped.

Is my data uploaded?

No — everything runs locally in your browser. Nothing is uploaded.

Related tools