Minify HTML Online — Whitespace-Safe, In Your Browser
Collapses whitespace and strips comments — while <pre> and inline semantics stay intact.
🔒 Runs in your browser — files never uploaded ⚡ No signup 💯 Free
Minify HTML by stripping comments and collapsing runs of whitespace — with the exceptions that make it safe: <pre>, <textarea>, <script> and <style> contents are preserved byte-for-byte, and conditional comments (the <!--[if …]> kind email templates need) survive.
Whitespace between inline elements collapses to a single space rather than nothing, because in HTML that space renders — removing it entirely would visibly glue words and buttons together.
How to use HTML Minifier
- Paste your HTML.
- Click Minify.
- Check the saving — indentation-heavy templates often shed 20–30%.
- Copy or download as an .html file.
The whitespace trap this tool avoids
In HTML, whitespace between inline elements is content: <a>one</a> <a>two</a> renders differently with and without that space. Minifiers that delete inter-tag whitespace wholesale change layouts in subtle ways that surface as "the links are stuck together" bug reports. Collapsing to a single space keeps rendering identical while still removing the indentation bulk — the safe 90% of the saving.
What's preserved exactly
<pre>and<textarea>— their whitespace is literally the content.<script>and<style>— JavaScript and CSS have their own rules; mangling them with HTML whitespace logic breaks both. Minify those separately with the JS and CSS minifiers, then inline.- Conditional comments — Outlook's email engine still reads them; stripping them silently breaks email templates.
Does HTML minification matter?
Less than it used to — gzip flattens repetitive markup extremely well. It still earns its keep on template-generated pages with deep indentation, and in emails, where some clients count raw bytes toward clipping limits (Gmail clips around 102 KB — raw, not gzipped).
Frequently asked questions
Why does it keep single spaces between tags instead of removing them?
Because that space renders. Inline elements separated by whitespace display with a gap; remove it and links, buttons and spans visibly glue together. Collapsing runs to a single space captures nearly all the size win with zero rendering change.
What happens to my inline scripts and styles?
Why did some comments survive?
Conditional comments (<!--[if mso]> and friends) are functional markup for Outlook's rendering engine — stripping them silently breaks email templates. Ordinary comments are removed.
Is minified HTML worth it for email?
More than for the web: Gmail clips messages around 102 KB of raw HTML — gzip doesn't help you there — and template indentation is often a third of the file. Minifying is the standard fix for clipped emails.