Developer Tools

HTML Minifier

Minify HTML by removing comments and collapsing whitespace while leaving pre, textarea, script and style content intact.

Tool

About the HTML Minifier

The HTML Minifier runs entirely in your browser — your data never leaves your machine. Paste, click and copy the result.

Every byte of markup is downloaded on every visit. This minifier strips comments, joins tags that sit on their own lines and collapses runs of spaces, while carefully protecting the content of pre, textarea, script and style blocks, where whitespace actually matters.

How to use this tool

  1. Paste your HTML into the input.
  2. Leave the comments option on to strip HTML comments.
  3. Click Minify HTML and copy the compressed markup.

What is preserved

  • All tags, attributes and text content.
  • Whitespace inside pre, textarea, script and style.
  • Conditional comments used for legacy browsers.

Developer tip

Because HTML collapses runs of ordinary whitespace to a single space anyway, minifying it is almost always safe. Still, diff the output against your source before shipping to catch anything unusual.

Who is this tool for?

Developers optimising page weight and anyone embedding HTML email or templates where every character counts.

Frequently asked questions

No. Content inside pre, textarea, script and style is protected and copied through unchanged.
HTML comments are removed by default; you can keep them by unticking Remove HTML comments. Conditional comments are kept either way.
No. Only comments and insignificant whitespace between tags are removed.

Related tools

Guides for this tool