HTML Minifier
Minify HTML code to reduce file size.
How to Use HTML Minifier
Paste your HTML into the input box, or upload an .html or .php template file.
Choose whether to drop HTML comments and whether to leave script and style blocks as they are.
Click the "Process" button to collapse whitespace, trim optional closing tags, and shorten attributes.
Copy or download the minified markup, then diff it against your original before shipping to be safe.
Features
Frequently Asked Questions
Related Tools
JSON Formatter
Format and beautify JSON data with proper indentation.
JSON Validator
Validate JSON data and find syntax errors.
JSON Minifier
Minify JSON by removing whitespace and formatting.
HTML Formatter
Format and beautify HTML code.
CSS Formatter
Format and beautify CSS code.
CSS Minifier
Minify CSS code for production.
About HTML Minifier
Every newline and repeated space in an HTML document is a byte your visitors download and your server compresses. The HTML Minifier collapses that whitespace, strips comments, removes optional closing tags, and shortens attributes so the same page ships as a fraction of its original size. On a markup-heavy page the difference is often 20 to 30 percent before gzip.
Safety is the hard part of HTML minification, and that is where this tool is careful. Text inside pre and textarea is whitespace sensitive, so it is protected completely. Script and style bodies are left alone by default rather than being mangled by a naive whitespace removal. Optional end tags are only dropped where the HTML specification explicitly allows it.
Attributes are normalised too. Boolean attributes lose their redundant value, quote characters around simple values are removed, and the obsolete type="text/javascript" is cleaned up. You get a real byte count before and after, and a diffable output so you can confirm the transformation is safe before shipping it.
When to Use This Tool
- Shrinking a static page or landing page before it goes to production
- Reducing the size of an HTML email template while protecting the layout
- Cleaning a WordPress or Shopify theme file for a production deploy
- Comparing two versions of a template by their minified output
- Preparing HTML for embedding in an email client or an in-app webview