HTML Minifier

Make HTML smaller by removing comments and extra whitespace while protecting pre, textarea, script and style.

Minified HTML

In short

What is the HTML Minifier?

The HTML minifier removes comments and extra whitespace between tags to reduce page size. Content inside pre, textarea, script and style elements is left untouched, and single spaces between inline elements are kept so text does not run together. It suits quick clean-ups of small pages and snippets.

How to use it

  1. Paste your HTML into the box.
  2. Tick keep comments if you need them.
  3. Copy the minified HTML.
  4. Open the page and check it still looks right.
Questions

HTML Minifier — FAQ

Will minifying change how my page looks?

It should not. Whitespace between inline elements is kept as one space. Still, always preview the result before publishing.

Are scripts and styles minified too?

No. Their contents are preserved exactly. Use the CSS minifier for stylesheets and a dedicated tool for scripts.

Does it remove conditional comments?

Comments that begin with an if condition for older browsers are kept. Other comments are removed unless you tick keep comments.

More Developer & Web tools