HTML Minifier

Make HTML pages smaller without breaking them. Comments and extra whitespace are removed, while <pre>, <textarea>, attribute values and conditional comments stay exactly as written.

Runs in your browser — nothing is uploaded Free, no limits

HTML input

Minified

Paste HTML or load the sample — it's minified in your browser as you type.

How to use the HTML Minifier

  1. Paste your HTML, open an .html file or load the sample.
  2. Choose whether to remove comments, collapse whitespace and minify inline <style> and <script> blocks.
  3. Compare the original, minified and gzip sizes.
  4. Copy the result or download it as an .html file.

Frequently asked questions

Is HTML minification safe?

This minifier is deliberately conservative. It removes whitespace only where browsers ignore it, keeps a single space between inline elements like <b> and <i>, and never changes attribute values or the contents of <pre> and <textarea>.

Why are some spaces kept between tags?

A space between inline elements is visible on the page — removing it would join words together. Spaces next to block elements like <div>, <p> or <li> don't render, so those are removed.

What are conditional comments and why are they kept?

Comments like <!--[if IE]> … <![endif]--> were used to target old Internet Explorer versions. They can contain working markup, so they're always kept even when other comments are removed.

What does "Minify inline CSS & JS" do?

It runs CSSO on <style> blocks and Terser on <script> blocks (classic and module scripts), and compacts JSON-LD. Blocks that fail to parse, or scripts of other types such as templates, are left unchanged.

How much does minifying HTML save?

Usually 5–20% before compression, more for heavily indented or commented templates. Since HTML is normally served with gzip or Brotli, check the gzip figures for the real saving.

Is my HTML uploaded?

No. Everything runs in your browser and nothing is sent to a server.