How to use the HTML Minifier
Minify your HTML in three steps:
1
Paste your HTML
Paste your formatted HTML into the input panel, or click the upload icon to load a .html file from your device.
2
Choose options and click Minify
Toggle 'Remove Comments', 'Collapse Whitespace', and 'Remove Empty Attributes' as needed, then click 'Minify HTML'. The output shows the compressed code along with file size before and after.
3
Copy or download
Click Copy to copy the minified HTML to your clipboard, or Download to save it as a .html file ready for deployment.
When to use this tool
Use the HTML minifier to reduce page weight and improve load performance:
- →Minifying static site HTML before deploying to a CDN or hosting provider
- →Reducing the size of HTML email templates before sending through an ESP
- →Compressing server-rendered HTML in build pipelines where templating engines add extra whitespace
- →Removing development comments from production HTML before shipping to users
- →Optimising landing pages for Core Web Vitals where every kilobyte of HTML counts
- →Compressing third-party widget HTML before embedding in pages
- →Reducing payload size in API responses that return HTML fragments
Frequently asked questions
Q:How much file size reduction can I expect from HTML minification?
Typical HTML files see 10–30% size reduction from whitespace and comment removal alone. Heavily indented HTML (4-space indent, deep nesting) or files with many comments can see reductions of 30–50%. The tool displays exact before/after byte counts and percentage saved so you can measure the impact precisely.
Q:Will IE conditional comments be removed?
No — the 'Remove Comments' option specifically preserves IE conditional comments (<!--[if IE]>…<![endif]-->) because they are functional markup, not documentation. Standard HTML comments (<!-- comment text -->) are removed.
Q:Is it safe to remove whitespace between tags?
In most cases yes — whitespace between block-level elements (div, section, header, etc.) has no visual effect and is safe to remove. However, whitespace between inline elements (span, a, strong, em) can affect text spacing in some cases. Review inline-heavy content after minification if precise text spacing is critical.
Q:What does 'Remove Empty Attributes' do?
This option strips attributes with empty string values such as class="", id="", style="", title="", and alt="". These add bytes without contributing information. Note: for some frameworks and libraries that rely on the presence of empty attributes as signals, review the output before deploying.
Q:Should I minify HTML manually or use a build tool?
For one-off pages, email templates, or quick optimisations, this online tool is the fastest option. For production websites with automated deployments, a build tool integration (html-minifier-terser in webpack/Vite, or a Gulp/Grunt plugin) is more maintainable. Use this tool to preview and benchmark the minification result before committing to a build pipeline change.
Q:Does the minifier alter the HTML structure or semantics?
No — only whitespace and comment nodes are removed. Tag names, attribute names and values (except empty ones if that option is enabled), text content, element order, and nesting structure are completely preserved. The minified HTML is semantically identical to the original.