Skip to content
← Back

HTML Minifier / Formatter - Online HTML Compression

Code
Runs locally · Not uploaded

Online HTML minification and formatting tool: compress by removing comments and whitespace, or format with proper indentation. Preserves script/style tag contents.

Was this result helpful?

For local tools, open DevTools → Network and search your input — it should not appear in requests.

Next steps

Usage Guide

Newlines, indentation, and ordinary comments inflate production HTML. Minify locally: optionally strip comments while keeping IE conditionals, skip script/style/pre/textarea/code interiors, and compare char vs UTF-8 byte savings.

1. Minify HTML

Inter-tag collapse can remove a visible space between adjacent inline elements — spot-check in a browser. Attribute-quote stripping and inline JS/CSS minify are out of scope; use js-minifier / css-minifier or build plugins.

  1. Paste HTML.
  2. Toggle: remove comments; keep IE conditional comments (only when removal is on).
  3. Minify; unclosed script/textarea surfaces a boundary warning.
  4. Read char/byte savings; use Format for readability.

2. When to minify

  • Email HTML size caps.
  • Small embed widgets.
  • Pair with css-minifier and js-minifier in a static pipeline.

3. Avoid

Next: Open Graph preview; sitemap generator for SEO pages.

  • Do not minify sources that still contain server template tags — minify rendered output.
  • Debug with html-formatter; minify before release.
  • Keep "Keep IE conditional comments" on if you still rely on them.

4. Compression ratio and safety bounds

Source HTML minify typically strips 10-20% — mostly comments, indentation, and blank lines. Do-not-touch: interiors of script/style/pre/textarea/code; conditional comments kept by default; semantic attributes in inline SVG. Unclosed preserve tags trigger a warning — interiors then follow normal whitespace rules. Diff the first screen before shipping.

5. The three-piece combo

HTML, CSS and JS compress differently: CSS/JS often reach 30-60% savings, HTML much less. Do sub-resources first (hashed filenames, minified content), then the container HTML. With CDN Brotli: source minification saves parsing and DOM size, transport compression saves bandwidth; they stack. The panel shows both characters and UTF-8 bytes so you do not over-read string.length.

FAQ

No. The page minifies as soon as it opens — processing happens locally, your HTML is never sent to any backend, and there's no usage cap.

By default it collapses whitespace between tags and strips ordinary HTML comments; IE conditional comments (<!--[if …]>…<![endif]-->) can optionally be kept. It does not strip attribute quotes or minify inline JS/CSS. The panel shows savings in both characters and UTF-8 bytes.

No. Interiors of <script>, <style>, <pre>, <textarea>, and <code> stay byte-identical, and unclosed versions of these tags trigger a warning. Hand inline scripts and styles to the JS/CSS minifiers instead.

Three categories: whitespace-dependent layouts inside <pre>/<code>, conditional comments you need to keep, and template-engine markers. Over-minification can break whitespace-sensitive preformatted content — render-check the output in the target browser before shipping.

Always keep the unminified master: ship the minified output, edit and roll back on the master. The site's JSON/XML formatters, regex tester, and other neighbors plug into the same pipeline.

Related Tools

Related Articles