HTML Minifier
Minify HTML by removing unnecessary whitespace and comments for a smaller output.
This tool runs entirely in your browser. Your files are never uploaded to a server.
<main><h1>Hello</h1></main>What this minifier does
Compacts HTML by removing ordinary comments, deleting whitespace between tags, and reducing runs of two or more whitespace characters elsewhere to one space. Complete pre, textarea, script, and style blocks are preserved unchanged when the simple matcher recognizes them; conditional comments beginning with [if are retained.
How to use it
Paste markup, inspect the immediate output, and copy it when ready. Reset clears the editor; no file is downloaded.
Important limitations
This is a regular-expression transformation, not an HTML parser, validator, sanitizer, optimizer, or compressor. It does not remove optional tags or quotes, rewrite attributes, minify embedded CSS/JavaScript, repair markup, or report errors. Malformed raw-text blocks, templates, unusual comments, and whitespace-sensitive inline content can produce unexpected or changed rendering.
Safe workflow and privacy
Keep the source, compare sizes, and test the result in target browsers before deployment. Processing is local and pasted HTML is not uploaded.
Frequently Asked Questions
- What does the HTML Minifier do?
- Minify HTML by removing unnecessary whitespace and comments for a smaller output.
- Does this HTML tool change program behavior?
- It only changes layout or removable whitespace. Review minified output before production use when code relies on unusual syntax.
- Is my code uploaded?
- Processing is local and your code is never uploaded.