HTML Minifier
Minify HTML
What Is This Tool?
The HTML Minifier shrinks HTML markup by stripping comments and collapsing whitespace between tags, reducing file size for faster page loads. It preserves the exact contents of <pre>, <script> and <style> blocks, and keeps IE conditional comments intact since they carry meaning. Everything runs locally in your browser.
How to Use
Paste your HTML into the input box.
Click Minify.
See the size reduction percentage.
Copy the result or download it as an .html file.
Features
- Removes HTML comments
- Keeps IE conditional comments intact
- Collapses whitespace between tags
- Preserves <pre>, <script> and <style> contents verbatim
- Shows before/after size reduction
- 100% client-side — nothing leaves your browser
Examples
Before:
<!-- header comment -->
<div class="card">
<p>
Hello <a href="/">world</a>
</p>
</div>
After (minified):
<div class="card"><p>Hello <a href="/">world</a></p></div>
Common Use Cases
- Shrinking static HTML before deploying to production
- Reducing page weight for faster load times
- Cleaning up generated markup before shipping
- Preparing compact HTML snippets for embedding
Frequently Asked Questions
Is my HTML uploaded anywhere?
No. Minifying happens entirely in your browser using JavaScript. Nothing is sent to a server.
Does it remove all comments?
It removes regular HTML comments, but keeps IE conditional comments (those starting with <!--[if) intact, since those affect rendering in older versions of Internet Explorer.
Does it touch content inside <script> or <style>?
No. Content inside <pre>, <script> and <style> tags is left exactly as-is so functionality and formatting-sensitive text are never broken.
Is this a full HTML parser?
No. This is a best-effort, regex-based minifier, not a full HTML5 parser. It handles standard markup well but may not cover every edge case of the spec.
How much smaller will my HTML get?
It depends on how much whitespace and how many comments your original markup has. The tool shows the exact percentage reduction after each run.
Can I download the result?
Yes, click Download to save the current output as a data.html file.