About the HTML Minifier
Reduce the size of an HTML page by removing comments and unnecessary spaces between tags. Whitespace inside pre, textarea, script and style is kept so nothing breaks.
HTML pages contain a surprising amount of whitespace and comments that browsers ignore: indentation, blank lines and developer notes. Removing them reduces the size of every page view, which slightly improves load time, especially for large static pages, landing pages and HTML emails where size limits apply.
This minifier removes comments and collapses whitespace between tags, and can optionally remove quotes around attribute values where it is safe. Whitespace inside <pre>, <textarea>, <script> and <style> is preserved so code and preformatted text keep working, and conditional comments for old Outlook and Internet Explorer are kept. The result shows how much smaller the page became and can be downloaded as a file.
How to use the HTML Minifier
- 1Paste your HTML.
- 2Choose the options (remove comments, collapse whitespace).
- 3Click Minify and copy the result.
Key features
- Remove comments.
- Collapse whitespace between tags.
- Optional removal of safe attribute quotes.
- Preserves pre, textarea, script and style.
- Size comparison and download.
Practical uses
- Shrinking static landing pages.
- Reducing HTML email size to avoid clipping in Gmail.
- Preparing embed snippets.
- Optimising pages on hosts without a build process.
- Reducing the size of HTML snippets embedded in JavaScript.
Example
A hand-written 40 KB page with indentation and comments commonly shrinks by 10–25%. The visible page is identical because browsers ignore the removed whitespace.
Tips and common mistakes
- Gmail clips messages larger than about 102 KB, so minifying email HTML can keep it whole.
- Keep an unminified copy for editing.
- Check inline elements after minifying, since spaces between them can affect layout.
- Run the HTML Formatter on minified output if you ever need to read it again.
Limitations
- Inline JavaScript and CSS are not minified; use the JS and CSS minifiers for that.
- Server compression usually saves more than minification alone.
Privacy
Minification runs in your browser.
Frequently asked questions
Is it safe for inline JavaScript?
Script and style contents are not changed, so inline code keeps working.
Are conditional comments kept?
Yes. Comments starting with <!--[if are kept.
How much will I save?
Usually 10–25% for hand-written HTML. Gzip on the server saves even more.
Why did space disappear between two links?
Collapsing whitespace can remove spaces between inline tags. Add a space inside the text or turn off collapse whitespace for that section.
Is it safe to remove attribute quotes?
Only for values without spaces or special characters, which is what the option does. Leave it off if another tool will process the HTML.
Does it minify inline CSS and JavaScript?
No. Content in style and script tags is kept as it is; minify it separately if needed.