Free HTML Minifier
Shrink HTML markup down by stripping comments and collapsing whitespace between tags, entirely in your browser.
Content inside <pre>, <textarea>, <script>, and <style> is left untouched so whitespace-sensitive text and code aren't broken.
How to minify HTML
-
1
Paste your HTML
Paste formatted or hand-written HTML markup into the input box.
-
2
Choose whether to strip comments
Leave the checkbox on to also remove HTML comments, or turn it off to keep them.
-
3
Click "Minify →"
Whitespace between tags is collapsed into a single compact block.
-
4
Copy the result
Click "Copy output" to grab the minified HTML for your page or template.
Example use cases
Shrinking a static page
Cut the byte size of a hand-written HTML page before deploying it without a build pipeline.
Preparing an email template
Compact nested table-based email markup before pasting it into an email service.
Embedding a snippet inline
Fit a chunk of HTML into a size-limited field, attribute, or config value.
Frequently asked questions
What does this minifier do?
It re-parses your HTML and prints it back out with the whitespace between tags collapsed and, optionally, comments removed — shrinking the markup without changing what it renders as.
Will it break whitespace-sensitive content?
No. Text inside <pre>, <textarea>, <script>, and <style> elements is copied through exactly as written, since collapsing whitespace there could change behavior or displayed formatting.
Does it validate my HTML?
No. Use the HTML Validator to check for unclosed or mismatched tags before minifying.
Is my markup uploaded anywhere?
No. Minifying happens locally in your browser using the DOM parser built into JavaScript — nothing you paste is sent to a server.