HTML Minifier
Compress HTML without breaking inline code.
Use the HTML Minifier tool
What this html minifier does
HTML Minifier removes HTML comments and repeated whitespace between tags, then reports the bytes saved. Content inside script, style, pre and textarea elements is preserved so that code samples and inline CSS or JavaScript keep working.
It is a conservative whitespace compressor, not an HTML optimiser: it does not remove unused CSS, rewrite attributes or inline assets. Always load the minified page and test it before replacing the original.
Why use it
- Shrink static pages before deploying them.
- Remove development comments from exported templates.
- Check how much of a page is whitespace and comments.
How to use it
- 1Paste the HTML.
- 2Read the before/after byte counts.
- 3Copy or download the minified output.
- 4Open the result in a browser and check layout and scripts.
Worked examples
Comment removal
Input
<!-- header --> <header> <h1>Title</h1> </header>
Output
<header><h1>Title</h1></header>
Preformatted code
Input
<pre> indented sample</pre>
Output
The indentation inside pre is kept.
Common mistakes
- Treating the output as verified; whitespace can be significant between inline elements.
- Minifying templates that rely on comments for server-side directives.
- Expecting the tool to fix invalid HTML; it only removes whitespace and comments.
Frequently asked questions
Is whitespace ever significant in HTML?
Does it remove attribute quotes?
Will it break my JavaScript?
Is the HTML uploaded?
Related tools
All toolsCSS Minifier
Compress CSS while keeping values intact.
JS Minifier
Strip JS comments and whitespace conservatively.
Meta Tag Analyzer
Audit the head of a page for SEO and sharing tags.
Word Counter
Words, characters, sentences, paragraphs and reading time.