HTML Minifier
Shrink HTML by removing comments and whitespace, safely.
How to use the HTML Minifier
- Paste your HTML on the left.
- It is compressed, leaving pre, textarea, script and style intact.
- Copy the smaller HTML.
About the HTML Minifier
The HTML Minifier shrinks your markup by stripping comments and collapsing runs of whitespace, so the file that reaches your users is smaller and faster to download. Paste your HTML on the left and the compressed version appears on the right, ready to copy into production.
Crucially, it does this safely. The contents of <pre>, <textarea>, <script> and <style> elements are deliberately left untouched, because whitespace inside them is significant: collapsing it could change how preformatted text displays, alter what a user sees in a text box, or break your JavaScript and CSS. By protecting exactly those regions, the minifier reduces size without the risk of silently breaking the page.
Everything runs in your browser, so your markup is never uploaded. To reverse the process and make compressed HTML readable again, use the HTML Beautifier, and to shrink the assets that go with your page reach for the CSS Minifier and JavaScript Minifier.
Frequently asked questions
What exactly does the minifier remove?
It strips HTML comments and collapses unnecessary whitespace between elements. The visible structure and content of the page stay the same, but the file is smaller and quicker to transfer.
Why are pre, textarea, script and style left alone?
Whitespace inside those elements is significant. Collapsing it could change preformatted text, alter a text box value, or break JavaScript and CSS, so their contents are deliberately preserved.
Will minifying break my page?
It is designed not to. By protecting the elements where whitespace matters, it avoids the common ways minification goes wrong, so the compressed markup renders the same as the original.
Can I undo the minification?
You cannot recover removed comments, but you can make the markup readable again by running it through the HTML Beautifier, which re-indents everything into a clean, nested layout.
Is my HTML sent to a server?
No. Minification runs entirely in your browser and nothing is uploaded, so it is safe to compress private or pre-release markup.

