HTML Minifier
Minify HTML by stripping comments and unnecessary whitespace
Minifies HTML by stripping comments and collapsing whitespace between tags, while leaving text content and the contents of script, style, pre, and textarea tags untouched.
How it works
It removes HTML comments and collapses whitespace runs that sit directly between a closing > and an opening < — purely structural whitespace, not whitespace inside your actual text content, which stays exactly as written. Anything inside <script>, <style>, <pre>, or <textarea> tags is preserved verbatim, since whitespace there is often meaningful (code indentation, preformatted text).
Frequently asked questions
Why doesn't it also collapse whitespace inside my text content?
Collapsing whitespace inside text nodes risks merging two adjacent inline elements' text together with no space between them — worse than a slightly larger file. Only whitespace that's purely structural, sitting directly between tags, gets removed.
Will it break my inline <script> or <style> code?
No — content inside script, style, pre, and textarea tags is preserved exactly as written, untouched by the whitespace collapsing that applies elsewhere, since minifying code or preformatted text the same way as markup could break it.
Why did it reject my HTML with an error?
Only when one of those preserved tags (script, style, pre, textarea) has a mismatched number of opening and closing tags — an unclosed tag can't be handled safely, since everything after it would be misread as still being inside it, so it's rejected outright rather than guessing.
Does it validate that my HTML is well-formed overall?
No — this is a best-effort minifier, not a full HTML parser or validator. It only checks that preserve-tags are balanced; other markup mistakes pass through without a warning.
Is my HTML sent anywhere?
No — minification runs entirely in your browser using JavaScript string processing. Nothing is uploaded.