Skip to content
Devtoolry

HTML Minifier

Minify HTML by removing comments and collapsing whitespace while preserving pre, textarea, script and style blocks.

About the HTML Minifier

The HTML Minifier shrinks pages by removing comments and collapsing whitespace, while leaving <pre>, <textarea>, <script> and <style> blocks untouched so nothing breaks.

Everything runs in your browser, so your input is never uploaded to a server.

How to use the HTML Minifier

  1. Paste HTML or open a file.
  2. Choose whether to remove comments.
  3. Copy or download the minified markup.

Frequently asked questions

Why are <pre> and <textarea> left alone?

Whitespace inside them is displayed to the user, so collapsing it would change the page.

Can I keep comments?

Yes. Switch off "Remove comments" to keep them, for example licence notices.