Strip whitespace, comments & redundant attributes from HTML — pure JS engine, zero dependencies, 100% in-browser. No file uploads. No size limits.
HTML minification is the process of removing unnecessary characters from HTML source code — such as whitespace, comments, redundant attributes, and blank lines — without changing how the page renders in a browser. The result is a smaller file that transfers faster over the network, reducing Time to First Byte (TTFB) and improving Core Web Vitals scores. A typical HTML document can be reduced by 15–40% in size through minification alone. When combined with server-side compression (gzip or Brotli), savings often exceed 80%.
HTML comments (<!-- ... -->) are human-readable notes that browsers ignore at render time. Minification strips them entirely. Similarly, blank lines between elements add bytes without contributing to output. Removing both typically saves 2–8 KB on a real-world page.
Multiple consecutive spaces and tabs between HTML tags are collapsed to a single space or removed. Indentation applied during development is for readability only — browsers parse the DOM tree identically whether there are 4 spaces or 0 spaces between elements. Whitespace inside <pre>, <textarea>, and <code> blocks is always preserved.
HTML5 makes certain attributes optional. type="text/javascript" on <script> tags and type="text/css" on <style> tags are both defaults — removing them is safe. Boolean attributes like disabled="disabled" can be shortened to just disabled. Redundant type="text" on input elements can also be safely dropped.
Minify any HTML file in under 30 seconds using this free online tool.
.html file from disk, or press Paste to read from clipboard. You can also try a built-in sample using the Load Sample section below the editor.index.min.html. Use Open in the Live Preview tab to verify the minified page renders exactly as expected before deploying.HTML minification directly improves three of the most important web performance metrics: Largest Contentful Paint (LCP), First Contentful Paint (FCP), and Time to First Byte (TTFB). When the browser receives a smaller HTML payload, it can begin parsing the DOM earlier, fetch critical resources sooner, and paint visible content faster.
For high-traffic websites, even a 5 KB reduction in HTML size can meaningfully reduce CDN bandwidth costs. A page serving 1 million requests per month that saves 5 KB per request saves approximately 5 GB of data transfer monthly — a real cost and latency win.
Google's PageSpeed Insights and Lighthouse both flag "Minify HTML" as an optimization opportunity when unminified HTML is detected. Addressing this recommendation contributes to higher Lighthouse Performance scores and can positively influence search ranking via Google's page experience signals.
| Option | What It Does | Safe to Enable? |
|---|---|---|
Remove HTML Comments |
Strips all <!-- --> comment blocks from the HTML output. |
✅ Always safe |
Keep Conditional Comments |
Preserves IE conditional comments (<!--[if IE]>). Enable if you support legacy IE browsers. |
⚠️ IE only |
Collapse Whitespace |
Reduces multiple spaces and tabs between tags to a single space. | ✅ Always safe |
Remove Blank Lines |
Deletes empty lines between tags that add bytes without any rendering effect. | ✅ Always safe |
Collapse to Single Line |
Outputs the entire HTML document on one line for maximum compression. | ⚠️ Test first |
Remove type="" on script/style |
Removes type="text/javascript" and type="text/css" — both are HTML5 defaults. |
✅ Always safe |
Shorten Boolean Attrs |
Converts disabled="disabled" to disabled, checked="checked" to checked, etc. |
✅ Always safe |
Minify Inline CSS |
Compresses CSS inside <style> blocks — removes comments, collapses rules, shortens hex colors. |
✅ Generally safe |
Minify Inline JS |
Strips comments and compresses <script> block content. Does not rename variables (use a full JS bundler for that). |
⚠️ Test first |
Comments stripped · Whitespace collapsed · type="text/javascript" removed · Blank lines eliminated
HTML minification is almost universally safe for production deployments, but there are a few scenarios where care is needed:
<pre> or <textarea> tags is always preserved by this tool, but custom elements may behave unexpectedly if they rely on text node whitespace. Always test with Live Preview.<!--[if IE]> blocks.For production workflows, integrate HTML minification into your build process rather than minifying manually every deployment. Popular tools that support HTML minification:
Complement HTML minification with these free tools for a fully optimized web project.