HTML Minify — Compress and Reduce HTML Size Online
🔒 Runs in your browser — nothing is sent to a serverHTML minify any pretty-printed or hand-formatted HTML into the smallest valid representation in a single click. Paste a server-rendered page, a marketing email, a Tailwind component or any HTML blob, and this HTML minifier strips whitespace between block tags, removes comments by default, shortens attribute quotes where safe and normalises boolean attributes to bare names. `<pre>`, `<textarea>`, `<script>`, `<style>` and conditional comments are preserved verbatim; mixed-content elements keep their significant whitespace. Output stats show how many bytes you saved. Everything runs 100% inside your browser; your input never leaves your device.
When to use an HTML minifier
You reach for an HTML minifier any time an HTML document needs to travel across a constrained channel: a server-rendered page where every kilobyte counts toward CDN bills and Lighthouse scores, an email template hitting an ESP with a per-message size cap, an inline `srcdoc` for an iframe, an offline-cached static asset, or an admin export being attached to a ticket. Browser-local minification means the payload never touches a server during the transform — important when the HTML carries CSRF tokens, internal URLs, customer PII or signed snippets you would rather not leak to a remote tool.
How HTML minifying works under the hood
HTML minifying is a three-step pipeline. First the input is scanned for the DOCTYPE; it is preserved verbatim because many email clients and parsers refuse to render documents without it. Second the input is fed through `new DOMParser().parseFromString(input, "text/html")`; the HTML parser is lenient, so almost any input parses. Third a recursive tree walker re-emits every element compactly: whitespace between block siblings is dropped, multi-space runs in text are collapsed to single spaces, attribute quotes vanish where safe, boolean attributes are shortened to bare names, and comments are removed unless "Keep comments" is ticked. `<pre>`, `<textarea>`, `<script>`, `<style>`, mixed-content elements and conditional comments stay exactly as they were. Optional toggles add inline-CSS minification, optional-closing-tag removal and default-attribute stripping.
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
<h1>Atlas</h1>
<p>Welcome to <strong>free-converter.online</strong>.</p>
</body>
</html><!DOCTYPE html><html lang=en><head><meta charset=UTF-8><title>Hello</title></head><body><h1>Atlas</h1><p>Welcome to <strong>free-converter.online</strong>.</p></body></html><section class="card">
<h2>Products</h2>
<ul>
<li>Atlas <em>(new)</em></li>
<li>Vesper</li>
</ul>
</section><section class=card><h2>Products</h2><ul><li>Atlas <em>(new)</em></li><li>Vesper</li></ul></section><article data-tool="html minify">
<h1>html minifier online</h1>
<p>Compress HTML inside your browser.</p>
</article><article data-tool="html minify"><h1>html minifier online</h1><p>Compress HTML inside your browser.</p></article><div>
<!-- production banner -->
<pre> if (a < b) {
x = 1;
}</pre>
<script>const y = 2;</script>
</div><div><pre> if (a < b) {
x = 1;
}</pre><script>const y = 2;</script></div>