HTML Minifier — Minify HTML Online Free
Minify HTML by removing whitespace and comments. Free, runs in your browser.
Input
Output
What Is HTML Minification?
Every kilobyte matters when you're optimizing page load time for a high-traffic site, and HTML is often left uncompressed while JS and CSS get all the attention. Minifying HTML means throwing away the bytes a browser never needed in the first place, such as the whitespace between tags, the comments and the doubled-up spaces, while the page renders exactly as before. Google's web.dev performance guide covers why reducing file sizes matters for Core Web Vitals. MDN HTML is the canonical reference for what each element does. Google PageSpeed Insights will flag large HTML files as opportunities. For serious production use, html-minifier-terser is the most widely used Node.js tool. This in-browser tool is great for quick checks and manual use without a build pipeline.
You get two modes on one page. Minify shrinks the markup for shipping, Beautify spreads it back out so you can read it, and either way the HTML is handled in your own tab rather than uploaded.
How to Use This Tool
Choose Mode
Select Minify to compress HTML by removing whitespace and comments, or Beautify to add indentation and make it readable.
Paste or Upload HTML
Drop your markup in the left pane or open an .html file with Upload. Sample gives you a small page with comments and indentation to squash.
Copy or Download Result
The right panel updates automatically. Use Copy or Download to save the result. For full HTML beautification, see the HTML Formatter tool.
HTML Minification Example
Below is an HTML snippet before and after minification:
Original HTML (with whitespace and comments)
Minified output
When Minification Matters
Minifying HTML reduces the number of bytes the browser needs to download. For small pages the difference is negligible, but for high-traffic sites or pages with large HTML the savings add up. Most production build tools (webpack, Vite, etc.) minify HTML automatically; this tool is for manual use or ad-hoc checks.
For readable, formatted HTML use the HTML Formatter tool.
Frequently Asked Questions
Does minification break HTML?
This tool removes HTML comments and collapses whitespace between tags. It does not remove attributes or modify tag content, so the resulting HTML should render identically in browsers.
Will it break inline <pre> or <textarea> content?
The simple whitespace collapsing used here may affect whitespace-sensitive elements like <pre>. For production use, consider a dedicated tool that handles these edge cases.
Is my HTML sent to a server?
No. All processing runs in your browser.
How much can minification reduce file size?
It depends on how much whitespace and how many comments the original has. Typical savings are 5–20% for developer-formatted HTML. Combined with gzip/Brotli compression on the server, the benefit is usually small.
Related Tools
See the HTML Living Standard for authoritative reference. Google's web.dev guide on minification covers the topic broadly. For CSS minification, see cssnano.