How to minify HTML
- Paste an HTML page or fragment. It is minified as you type.
- Leave Remove whitespace between tags off for safe results, or tick it for the smallest output once you have checked your layout.
- Copy the result or download it.
What gets removed and what is kept
The HTML minifier strips comments (but keeps Internet Explorer conditional comments), collapses runs of spaces, tabs and line breaks to a single space, and tidies spaces inside tags. Inline <style> blocks are minified with the CSS minifier.
Content where whitespace matters is protected: <pre> and <textarea> are left exactly as written, and <script> blocks are kept intact so code is never damaged.
Why is removing whitespace between tags optional? Between inline elements such as links, buttons or <span>s, a space is visible on the page. Removing it can glue words or buttons together. Between block elements like <div> and <li> it is harmless. Check your page after using the aggressive option.
Minified HTML is smaller to download and parse, which helps on slow networks and for HTML emails, where some clients clip messages over a size limit (Gmail clips at 102 KB). All processing happens locally in your browser.
FAQ
Does minifying HTML improve SEO?
Indirectly. Smaller pages load faster, which helps Core Web Vitals, but search engines read minified and unminified HTML the same way.
Why does Gmail clip my email?
Gmail clips messages whose HTML exceeds about 102 KB. Minifying the HTML is an easy way to get under the limit.
Is inline JavaScript minified?
Script blocks are left unchanged for safety. Minify them separately with the JavaScript minifier if needed.