Skip to content

HTML Minifier

✨ Minifies as you type 0 B

Minified HTML

Comments and extra spaces are removed. Your page looks the same.

HTML Minifier – Free Online Tool

What is an HTML Minifier?

An HTML minifier makes your HTML file smaller without changing what the page looks like. While you write code, indentation, line breaks and comments help you (and your teammates) read it. The browser doesn’t need any of that, so before you ship the page you can strip it out.

Smaller files download faster, especially on slow phones, and every byte saved adds up on busy pages. It’s one of the easiest performance wins there is: paste, copy, done. Everything runs in your browser, so your code never leaves your device.

How to Use It – Step by Step

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 (roughly what visitors really download).

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. The minifier keeps one space wherever a space actually shows on the page.

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.

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.

Frequently Asked Questions

Will minifying change how my page looks?

No, that’s the whole point. It only removes things the browser ignores anyway: comments, line breaks and extra spaces between tags. One spot needs care: if your CSS turns list items or links into inline-block boxes, the tiny gap between them can disappear. Check the page after minifying if you use that trick.

What exactly gets removed?

HTML comments (except old IE conditional comments), line breaks and indentation between tags, and extra spaces. A single space is kept wherever it matters between words or inline elements. The content of <pre>, <textarea>, <script> and <style> is left alone, apart from trimming scripts and styles.

How much smaller will my HTML get?

It depends on how much indentation and how many comments you have. Hand-written, nicely indented HTML often shrinks by 15–35%. HTML from a CMS or page builder can shrink more. The Saved number above the output shows your exact result.

My server already uses gzip. Is minifying still worth it?

Usually yes, but the gain is smaller than the raw numbers suggest, because gzip is already great at squeezing whitespace. That’s why we show the gzipped size too: it’s roughly what visitors actually download. For a big page every kilobyte still helps load time a little.

Can I get my nicely formatted HTML back?

Not the exact original, because comments are gone for good. But you can make minified HTML readable again in a second with our HTML Formatter. Keep your original source file and only upload the minified copy.

Does it minify CSS and JavaScript too?

No. It focuses on the HTML itself. Inline <style> and <script> blocks are kept as they are (just trimmed), so nothing can break. Use a dedicated CSS or JS minifier, or your build tool, for those.

Is my HTML uploaded?

No. Minifying happens entirely in your browser. Nothing is sent to our server.