Asistente RD

HTML minifier

Minify HTML in your browser: strip comments and whitespace between tags without breaking pre, textarea, script or style. See the bytes and percentage you save.

Free · No sign-up · In your browser

Original size

148 bytes

Minified size

99 bytes

Savings

33.1%

Minified HTML

<div class="card"><h1>Hola mundo</h1><p>Bienvenido al portal.</p><pre> line 1 line 2</pre></div>

Everything runs in your browser: your HTML is never sent to any server.

Share on WhatsApp Last reviewed: July 9, 2026

Minify your HTML without breaking anything

The HTML minifier shrinks your markup by stripping what the browser doesn’t need: comments, line breaks and indentation, and the leftover whitespace between tags. The output is smaller, travels faster over the network and shaves a little off your load time and performance metrics — all without changing how the page looks or behaves.

Everything happens in your browser: paste the HTML, get the minified version instantly, and your code is never sent to any server.

How to use it

  1. Paste your HTML into the input box.
  2. Copy the minified HTML with the button (or check the bytes and percentage you saved).
  3. Drop it into your project, email template or static file.

What it does exactly

  • Removes comments <!-- ... -->.
  • Collapses every run of spaces, tabs and line breaks into a single space.
  • Deletes the gap between tags: the whitespace sitting between a > and the next < is removed entirely.
  • Leaves untouched the contents of <pre>, <textarea>, <script> and <style>, plus quoted attribute values. A stray space does matter there, so it stays put.
ElementMinified?
Comments <!-- -->Removed
Whitespace between tagsRemoved
Multiple spaces in textCollapsed to one
<pre> and <textarea> contentPreserved
<script> and <style> codePreserved
Attribute valuesPreserved

Worked example

Start from this HTML with a comment, indentation and a <pre> block:

<!-- Product -->
<div class="card">
    <h1>Hello   world</h1>
    <p>Welcome to the portal.</p>
    <pre>  line 1
  line 2</pre>
</div>

That’s 137 bytes. After minifying we get:

<div class="card"><h1>Hello world</h1><p>Welcome to the portal.</p><pre>  line 1
  line 2</pre></div>

Now it’s 99 bytes — a 27.7% saving. Notice three things: the comment is gone, the triple space in “Hello world” collapsed to one, and the meaningful indentation inside <pre> was kept line by line.

Frequently asked questions

Does minifying HTML help SEO?

Indirectly. Google doesn’t reward markup for being minified, but a lighter file loads a touch faster, and speed is a real experience signal. The impact is small next to compressing images or enabling gzip/Brotli on the server, but it adds up and it’s free.

Can it break my page?

It shouldn’t. The tool never touches the contents of <pre>, <textarea>, <script> or <style>, nor your attribute values — the places where an extra space would change the outcome. Everywhere else HTML ignores repeated whitespace, so collapsing it is safe.

Should I keep the unminified HTML too?

Yes. Always work on the readable (indented) version and minify only the copy you ship. If you later need a comfortable-to-read format again, use the HTML formatter, which does the opposite: it puts line breaks and indentation back.

Is it useful for HTML emails?

Yes, and it shows there: many email clients have size limits and clip long messages (Gmail clips around 102 KB). Minifying the email’s HTML helps you stay under the limit.

Is my HTML uploaded anywhere?

No. The whole process runs in your browser with JavaScript. You can paste private code and it never leaves your machine.

Related tools