Online HTML minification and formatting tool: compress by removing comments and whitespace, or format with proper indentation. Preserves script/style tag contents.
TL;DR: Free online HTML minifier with optional comment stripping, IE conditional-comment keep, safe script/style/pre/textarea boundaries, and char vs UTF-8 byte savings — runs locally.
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.
- Paste HTML.
- Toggle: remove comments; keep IE conditional comments (only when removal is on).
- Minify; unclosed script/textarea surfaces a boundary warning.
- 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
Online HTML Minifier: Reduce HTML File Size for Faster Loading
Learn how to compress HTML to cut file size. Cover minification strategies, optional comment stripping and IE conditional comments, script/style/textarea boundaries, and char vs UTF-8 byte savings in an online tool.
Online CSS Minifier: Reduce CSS File Size for Better Performance
Learn how to minify CSS safely: whitespace, comments, hex shortening, zero-unit elision, calc protection, and UTF-8 byte savings — with an online tool you can use locally.
Unexpected token '<' is not valid JSON — 5 Reasons Your API Returned HTML Instead
fetch throws SyntaxError: Unexpected token '<' when the response body is HTML, not JSON. Covers the 5 root causes: SPA history fallback returning index.html, auth 302 redirects, gateway 502 error pages, wrong baseURL, and missing res.ok checks — with curl diagnostics.