The HTML Minifier reduces the size of your markup by collapsing the whitespace between tags and, if you choose, removing comments. The visible content of the page is unchanged, but the bytes spent on indentation, blank lines and developer notes are stripped away, producing markup that downloads faster and takes up less space.
It is aimed at developers shipping static pages, email markup or embedded snippets where every kilobyte matters, and at anyone who wants a compact version of a document for storage or transport. Smaller HTML means quicker first paint for visitors and leaner payloads for systems that pass markup around as strings.
Everything runs locally in your browser using JavaScript, so the HTML you paste is never uploaded, logged or stored. That lets you minify unpublished pages, internal templates and markup containing private content without any of it leaving your own device.
Features
- Collapses the whitespace between tags so indentation and blank lines no longer bloat the file.
- Optionally removes HTML comments, stripping developer notes and conditional annotations.
- Preserves pre, textarea, script and style blocks exactly so code and preformatted text survive.
- Reduces the byte size of markup without changing what a browser actually renders.
- Reports the original and minified character counts plus the percentage of size you saved.
- Handles whole documents or small fragments equally well for pages, emails and snippets.
- Copies the minified markup or downloads it as a file ready to deploy.
How to use HTML Minifier
- Paste your HTML document or fragment into the input box.
- Leave the remove-comments option on to strip developer notes, or turn it off to keep them.
- The tool instantly collapses whitespace and produces the compact markup.
- Check the statistics to see how many characters and what percentage you saved.
- Copy the minified HTML or download it as a file to deploy on your site or in your email template.
Benefits
- Smaller HTML downloads faster, improving load time and perceived performance for visitors.
- Leaner markup reduces bandwidth costs and payload size for high-traffic pages.
- Removing comments strips internal notes before markup ships to a public page.
- Compact HTML is easier to embed as a string in code, email templates or configuration.
- The size statistics quantify exactly how much smaller the document became.
- Because minification is local, unpublished and private markup never leaves your device.
Whitespace in HTML is mostly for humans. Browsers collapse runs of spaces and newlines when rendering most content, so removing that whitespace between tags has no visual effect while trimming real bytes. The exception is whitespace-sensitive content, which is why the minifier carefully protects pre and textarea blocks along with script and style, leaving their contents exactly as written.
Removing comments is optional because comments sometimes carry meaning. Templating systems and older conditional comments can rely on comment syntax, so you can keep comments when they are load-bearing and strip them when they are merely developer notes. When enabled, comment removal is a quick way to ensure internal remarks never reach a page your visitors can view the source of.
This is a whitespace and comment minifier rather than a full optimiser, so it does not rewrite attributes, remove optional tags or shorten inline styles. That conservative approach keeps the output safe and predictable: what the browser renders after minification is the same as before, just delivered in fewer bytes. For maximum compression you can combine it with server-side gzip or Brotli, which stack cleanly on top.