An HTML minifier removes comments and extra whitespace from your code, so the file is usually smaller. Indentation
and line breaks help you (and your teammates) read the code, but browsers can usually show the same page without
them. Your HTML comments never show on the page either.
A smaller file means less to download, though the difference can be tiny on a small page. Everything runs in
your browser, so your code never leaves your device.
Three quick steps, plus two little examples so you know exactly what happens to your code.
Step 1 Paste or Open Your HTML
Put your HTML in the left panel. Any of these work:
- Paste it: copy from your editor, CMS or build output.
- Open a file: click the upload button or drag an .html file onto the page.
- Sample: loads a small messy page so you can see the result right away.
Step 2 Watch It Shrink
The minified HTML appears on the right as you type, with the numbers above it: the original size, the
minified size, how much you saved, and the gzipped size. That last one estimates how big the minified HTML
would be if your server sends it with gzip.
Example: comments and indentation go away
Before:
<!-- Main navigation -->
<nav class="menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog">Blog</a></li>
</ul>
</nav>
After:
<nav class="menu"><ul><li><a href="/">Home</a></li><li><a href="/blog">Blog</a></li></ul></nav>
Example: spaces between words are kept
Before:
<p>
Hello <strong>friend</strong>,
welcome back!
</p>
After:
<p>Hello <strong>friend</strong>, welcome back!</p>
💡 Notice “Hello friend, welcome back!” still reads correctly. There’s one space on each side of “friend,” and the extra spaces before “back” are gone.
Step 3 Copy or Download
Click Copy and paste the result into your project, or Download a
.min.html file. Keep your original, readable file for editing, and only ship the minified copy.
Check how that copy looks with your CSS first.
Good to know: pre-formatted text is safe
Whitespace inside <pre> and <textarea> matters, so the minifier leaves it exactly as it is:
<pre>
line one
line two
</pre>
Need to read a minified file later? Paste it into the HTML Formatter to get
clean indentation back, or check it with the HTML Validator first. Want to see
how it renders? Use the HTML Viewer.
For code in separate files, use the CSS Minifier, or pick Minify in the JavaScript Formatter.
To remove inline styles, classes or empty tags from your HTML, use the HTML Cleaner.
Will minifying change how my page looks?
Usually not, but your CSS can make a difference. If your <li> menu items use display: inline-block, the small gap between them can disappear. Text with white-space: pre-wrap can lose its line breaks, unless it’s inside a <pre> or <textarea>. Check the minified page with your CSS before you publish it.
What exactly gets removed?
HTML comments (except old IE conditional comments), plus extra spaces and line breaks. Words and inline tags keep a single space between them if there was one, like the space in <a href="/">Home</a> <a href="/menu">Menu</a>. All the spacing inside <pre> and <textarea> is kept. It doesn’t remove attributes, quotes or closing tags, so <input type="text" disabled="disabled"> stays the same.
How much smaller will my HTML get?
It depends on how many comments and extra spaces you have. The menu example in Step 2 goes from 137 bytes to 95, but that’s a tiny snippet with a comment in it. If your HTML is already minified, it may not shrink at all. Check the Saved number above the output to see your result.
Is minifying HTML the same as gzip compression?
No. Minifying removes comments and extra spaces, and the result is still normal HTML. Gzip packs the file while it’s being sent, and the browser unpacks it. The Gzipped number is only an estimate. Download saves a normal .min.html file, not a gzip file.
My server already uses gzip. Is minifying still worth it?
It can be, but you’ll usually save less than the Saved number suggests. Gzip already shrinks repeated text and spaces well. To compare, note the Gzipped size for your minified HTML. Then use your browser’s network tools to check how much data your original page sends. Your server may use different compression settings, so the two numbers won’t match exactly.
Can I get my nicely formatted HTML back?
Not the exact original, because the comments and original spacing are gone. The HTML Formatter can still make minified HTML easier to read. Keep your original source file and only upload the minified copy.
Does it minify CSS and JavaScript too?
No, it only minifies the HTML. Code inside <style> and <script> tags stays the same, except for extra space at the start and end. For CSS files, use the CSS Minifier. For JavaScript files, use Minify in the JavaScript Formatter.
Is my HTML uploaded?
No. Minifying happens entirely in your browser. Nothing is sent to our server.