HTML Minifier
Minify HTML by stripping comments, collapsing whitespace, and tightening tags. Runs entirely in your browser.
Runs in your browser — nothing uploaded
HTML input—
Minified
Use this free HTML minifier to shrink your markup for faster page loads. It removes comments, collapses whitespace, and tightens tag gaps — while leaving the contents of pre, textarea, script, and style tags untouched so your code samples and inline scripts still work.
Private by design — your data never leaves your device
How to use it
No account, no upload — it all happens on your device.
1
Paste your HTML into the input box.
2
Toggle the options to control comments, whitespace, and tag-to-tag gaps.
3
Copy the minified output from the right panel.
What gets removed
A breakdown of every change a minifier makes — and why each one is safe.
| Change | Before | After |
|---|---|---|
| Comment | <!-- TODO --><div> | <div> |
| Indent + newlines | <ul> <li>a</li> </ul> | <ul><li>a</li></ul> |
| Double spaces inside text | <p>Hello world</p> | <p>Hello world</p> |
| Tag-to-tag whitespace | </li> <li> | </li><li> |
What gets preserved
Some whitespace matters. The minifier leaves these zones alone.
<pre>blocks — indentation and line breaks are visual content here.<textarea>values — the initial value of a form control is preserved character-for-character.<script>content — JavaScript is left as-is. Use a JS minifier separately if you want to compress it.<style>content — inline CSS is left as-is. Use the CSS Minifier for that.
When to minify
- Production builds. Even with gzip/brotli, a pre-minified payload is smaller because compression operates on smaller input.
- Email HTML. Many email clients have payload limits; shaving comments and whitespace can push a borderline template under the cap.
- Inline static fragments. Anything you embed inside a JSON payload or a template literal benefits from tighter markup.
Don't minify HTML you're still editing — readable source beats a few saved bytes during development.
Frequently asked
What does this minifier change?
It strips HTML comments, collapses runs of whitespace to a single space, and removes whitespace between tags. Content inside <pre>, <textarea>, <script>, and <style> blocks is left exactly as it was.
Is my HTML uploaded anywhere?
No. The minifier runs entirely in your browser. Your markup never leaves the page.
How much smaller will my HTML get?
Typical hand-written HTML shrinks 20–40% after minification. Markup that was already terse may save very little; markup generated by a templating engine often saves more.