HTML Minifier
🔒 In your browserMinify HTML to speed up pages — preserves pre, script & style blocks.
How it works
Shrink HTML by removing comments and unnecessary whitespace, making pages load faster. Content inside <pre>, <textarea>, <script> and <style> is preserved so nothing breaks.
Try an example
—🔒 Generated entirely in your browser — nothing is uploaded.
🔒 Runs in your browser: tags, sitemaps and minification are generated locally from what you type — nothing is uploaded, no signup, no limits.
About the HTML Minifier
This free HTML minifier shrinks your markup by removing comments and collapsing unnecessary whitespace, so pages download and render faster. It's deliberately conservative — the contents of pre, textarea, script and style tags are preserved exactly, so minifying never breaks your page or code samples.
Everything runs in your browser; your HTML is never uploaded.
What it does
- Removes HTML comments (keeping IE conditional comments).
- Collapses runs of whitespace and removes it between tags.
- Preserves whitespace-sensitive content inside pre, textarea, script and style.
Why it's conservative on purpose
Whitespace is significant inside some HTML tags — collapse it and you break the page. This minifier removes comments and collapses whitespace between tags, but deliberately leaves the contents of pre, textarea, script and style untouched, and keeps single spaces between inline elements so text doesn't run together. The result is smaller HTML that renders exactly the same.
Frequently asked questions
Will minifying break my page?
This minifier is conservative by design: it leaves the contents of pre, textarea, script and style untouched and keeps single spaces between inline elements, so layout and code samples are preserved.
How much smaller will my HTML get?
It depends on how much whitespace and how many comments the file has — typically a modest but worthwhile reduction. The tool shows the before and after size and the percentage saved.
Should I minify the inline CSS and JavaScript too?
This tool preserves script and style contents. To minify those, paste them into the dedicated CSS Minifier and JavaScript Minifier.
Is my HTML uploaded?
No. Minification happens entirely in your browser.
Should I minify the inline CSS and JavaScript too?
This tool preserves script and style contents to stay safe. To minify those, paste them into the dedicated CSS Minifier and JavaScript Minifier.
Related searches
Learn more
Related SEO tools
🔗 Embed this tool on your website — free
Copy this and paste it into your page's HTML. The tool runs in the visitor's browser, just like here. Change height to fit, or add the optional auto-resize snippet below. Add ?theme=dark to the URL for dark mode.
<iframe src="https://toolhq.dev/embed/html-minifier/" title="HTML Minifier — ToolsHub" width="100%" height="520" style="border:1px solid #e5e7eb;border-radius:12px;max-width:680px" loading="lazy"></iframe>Optional: auto-resize the iframe height
Add this once on the same page so the iframe grows to fit the tool:
<script>
addEventListener("message", function (e) {
if (e.data && e.data.type === "toolshub:resize") {
document.querySelectorAll('iframe[src*="/embed/"]').forEach(function (f) {
if (f.contentWindow === e.source) f.style.height = e.data.height + "px";
});
}
});
</script>