HTML Minifier
Paste your HTML and minify it instantly — remove comments, whitespace, optional tags, and more
Paste bloated HTML, get a smaller file back — comments stripped, whitespace collapsed, optional closing tags removed. Toggle each rule on or off depending on what your project actually needs. And everything runs in your browser. Nothing gets uploaded.
How It Works
Paste your source HTML on the left. Pick your options — comment removal, whitespace collapsing, optional tag stripping, quote cleanup, or default attribute removal. Hit Minify and the compressed output shows up on the right with a size comparison bar so you can see exactly how many bytes you shaved off. Grab it with the copy button or download as an .html file.
Examples
Removing Debug Comments Before Deployment
You left TODO notes and section markers scattered through a production page. Time to ship clean HTML.
<!-- TODO: fix nav links -->
<nav>
<!-- Main navigation -->
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
<nav><a href=/>Home</a> <a href=/about>About</a></nav>
Flattening a Heavily Nested Template
Template engines love deep indentation. Six levels of tabs in a Blade or EJS file add kilobytes of whitespace that browsers ignore completely.
<div class="wrapper">
<div class="container">
<div class="row">
<div class="col">
<p>Hello</p>
</div>
</div>
</div>
</div>
<div class=wrapper><div class=container><div class=row><div class=col><p>Hello</div></div></div></div>
Shrinking an Email Template Under Gmail’s Clip Limit
Gmail clips emails over 102KB. Your newsletter is at 108KB. Minifying the HTML gets it down to 89KB — no more "[Message clipped]" link hiding your CTA button.
<table width="600" >
<tr>
<td style="padding: 20px;
font-family: Arial;">
<p style="color: #333333;
font-size: 14px;">
Welcome!
</p>
</td>
</tr>
</table>
<table width=600><tr><td style="padding:20px;font-family:Arial"><p style="color:#333;font-size:14px">Welcome!</table>
Who Uses This
Minify static site HTML before deployment to cut first-paint time on high-traffic pages.
Squeeze newsletter templates under Gmail’s 102KB clipping threshold so CTAs don’t get hidden.
Copy rendered theme output, minify it, and paste into custom HTML blocks without touching PHP.
Learn which parts of HTML are actually required and which parts browsers can figure out on their own.
Common Mistakes
Minified HTML is a wall of text. If something breaks later, you can’t debug it. Always keep your original source files separate and only minify the production copy.
HTML minification only touches HTML-level whitespace and tags. Your <script> and <style> blocks stay untouched. Run those through dedicated CSS and JavaScript minifiers separately.
Browsers handle missing </td> and </tr> just fine. Outlook 2016? Not so much. Test email templates in actual email clients after minifying, especially if you strip optional tags.
Technical Details
- Processing: 100% client-side — nothing leaves your browser
- Max Input: Limited by browser memory (tested up to 5MB files)
- Output: Copy to clipboard or download as .html
- Browser Support: Chrome, Firefox, Safari, Edge
- Dependencies: None — pure JavaScript, no external libraries
Frequently Asked Questions
Does minifying HTML actually make pages faster?
It depends on the page. Small pages might save 1-2KB — barely noticeable. But large pages with heavy commenting and deep nesting can shrink 15-30%. On a high-traffic site, even a few KB per page adds up to gigabytes of saved bandwidth each month.
Is it safe to remove optional HTML closing tags?
Yes, the HTML spec explicitly marks tags like </li>, </p>, and </td> as optional. Every modern browser handles them fine. Google’s own pages drop optional tags. The one exception: if you’re targeting XHTML strict mode or feeding HTML to an XML parser, keep them.
Will this break my CSS or JavaScript?
No. HTML minification only affects HTML-level whitespace, comments, and attributes. The contents inside <style> and <script> blocks are left alone. You’d need separate minifiers for those.
Can I reverse HTML minification?
Not completely. Comments are permanently gone, and original indentation can’t be recovered. A beautifier will add readable formatting back, but it won’t match your original code style. That’s why you should always keep the source file and only minify for production.
Should I still minify if my server uses gzip?
Absolutely. They complement each other well. Gzip compresses repeated patterns, so feeding it already-minified HTML means a smaller input and better compression ratio overall. Most production setups do both — minify the source, then gzip during transfer.