HTML Minifier

Strip whitespace and comments to shrink your HTML files.

Minifying HTML removes what the browser does not need: indentation, line breaks, comments, and redundant attribute quotes. The rendered page is identical; the file is smaller.

Minifying your HTML

  1. Paste your HTML into the box above.
  2. Minify it.
  3. Copy the compressed output.
  4. Test the result properly — minified HTML is very hard to debug by eye.
  5. Keep your formatted source as the file you actually edit.

How much this is actually worth

Be realistic. HTML minification typically saves 10–20% of the raw file size, and gzip or Brotli compression — which your server almost certainly already applies — captures much of that saving anyway. The incremental gain on top of compression is often modest.

Where it does matter is on large pages, on high-traffic sites where small percentages multiply, and on slow mobile connections. It is worth doing as part of a build step. It is not worth doing by hand, and it is not where your biggest performance win lives — that is almost always images or blocking scripts.

What a minifier removes

  • Indentation and line breaks between tags.
  • HTML comments, except conditional ones that still matter.
  • Redundant attribute quotes where the value has no spaces.
  • Optional closing tags that the parser can infer.
  • Whitespace inside attribute values where it is not significant.

The whitespace trap

Whitespace between inline elements is not meaningless. Two <span> elements separated by a newline render with a space between them; joined together they render with none. Aggressive minification can close gaps that were doing visual work, and inline-block layouts are especially sensitive to this.

A good minifier preserves significant whitespace, but always check the rendered result rather than assuming. And never minify the contents of <pre> or <textarea>, where every space is meaningful.

HTML minification questions

How much smaller will my HTML get?

Typically 10–20% before compression. Once gzip or Brotli is applied the additional saving is smaller, because those algorithms already handle repeated whitespace efficiently.

Does minifying HTML break anything?

It can, if whitespace between inline elements was contributing to the layout, or if content inside <pre> tags gets collapsed. Test the rendered page rather than trusting the diff.

Should I minify by hand or in a build step?

Always in a build step. Keep readable source in version control and generate the minified output automatically, so you never have to edit compressed HTML.

Is minification worth it if I already use gzip?

Marginally. Compression captures most of the same redundancy. It is worth including in a build pipeline because it costs nothing, but it will not transform your performance on its own.

Does minified HTML help SEO?

Only indirectly, through page speed. Search engines parse minified and formatted HTML identically, so there is no direct ranking effect.

Cookie
We care about your data and would love to use cookies to improve your experience.