How to use HTML Minifier
- Paste the HTML.
- Toggle the options you want (quotes removal is off by default).
- Copy the compact result and check the size savings.
HTML Minifier features
- Collapses whitespace between tags and inside text
- Removes comments while keeping conditional (<!--[if IE]>) and <!--! comments
- Optional removal of attribute quotes where HTML5 allows it
- Minifies inline <style> and <script> blocks
- Removes redundant attributes (type="text/javascript", type="text/css", method="get")
- Never touches <pre> and <textarea> content
HTML Minifier example
Minify a snippet
Input:
<div class="a">
<p>Hello <b>world</b></p>
<!-- note -->
</div>Output:
<div class="a"><p>Hello <b>world</b></p></div>Frequently asked questions about HTML Minifier
Is whitespace inside <pre> and <textarea> affected?
No. Those elements keep their content exactly; only whitespace between tags and inside regular text is collapsed.
Which comments are removed?
Regular <!-- comments --> are removed. Conditional comments (<!--[if IE]>) and comments starting with <!--! are kept when "Keep conditional comments" is on.
Is removing attribute quotes safe?
Quotes are only removed when the value contains no spaces, quotes, =, <, > or backticks, which is valid HTML5. Leave the option off if your toolchain requires quoted attributes.
Does it minify inline CSS and JavaScript?
Yes. <style> content goes through the CSS minifier and <script> content (JavaScript types only) through the JavaScript minifier.