HTML Minifier
Strip comments and collapse whitespace while safely preserving pre, script, and style blocks.
How to Minify HTML
- Paste your HTML into the input box.
- The minified version appears instantly below.
- Copy the result.
Frequently Asked Questions
What exactly does this minifier do?
It removes HTML comments and collapses runs of whitespace (spaces, tabs, and line breaks) down to a single space between tags and within regular text content — both purely cosmetic changes that don't affect how the page renders in normal cases.
Does it preserve the content of <pre>, <script>, and <style> tags?
Yes — the exact contents of <pre>, <script>, <style>, and <textarea> tags are protected and left completely untouched, since whitespace inside those elements is often meaningful (preformatted text) or would break the code (JavaScript and CSS).
Could collapsing whitespace ever change how a page looks?
In rare cases, yes — if you're relying on multiple consecutive spaces rendering visually inside an inline element (browsers already collapse most repeated whitespace by default, but not always identically to this tool). For typical HTML documents this isn't noticeable, but it's worth spot-checking anything with unusual manual spacing.
Is my HTML sent anywhere?
No — the minification happens entirely in your browser using JavaScript, so nothing you paste in is ever sent to a server.