HTML minifier

Paste HTML to make it smaller. Comments and spaces that browsers ignore are removed, while the content of pre, textarea, script and style stays exactly as written. The saving is shown in bytes.

Saved 23% (292 → 225 bytes).

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Paste your HTML.
  2. Choose whether comments are removed, and whether safe attribute quotes are dropped.
  3. Copy the result. The line under it shows how many bytes were saved.

How it works

The HTML is read tag by tag with a small tokenizer. Text between tags is collapsed: runs of spaces, tabs and line breaks become one space, and that space is removed at the edges of block elements, where it has no visible effect. Raw-text elements (pre, textarea, script, style) are copied as they are.

Example

<ul>
  <li> One </li>
  <!-- note -->
  <li>Two <em>x</em> y</li>
</ul>

becomes <ul><li>One</li><li>Two <em>x</em> y</li></ul>.

Tips

Whitespace around inline elements can change how a page looks, so the minifier keeps one space there. If you rely on white-space: pre in CSS, check the result visually. Compression such as gzip or Brotli on the server saves much more than minifying, and works together with it.

Frequently asked questions

What does the minifier remove?

Comments, whitespace between block elements such as div, p and li, and repeated spaces or line breaks in text. A single space between inline items such as words and links is kept, because it is visible on the page.

What is never changed?

Everything inside pre, textarea, script and style, byte for byte, and Internet Explorer conditional comments like <!--[if IE]>. No tag is added, removed or reordered.

When are attribute quotes removed?

Only if you turn the option on, and only for values that HTML allows without quotes. The value must not be empty and must not contain spaces, quotes, =, <, > or a backtick, and must not end with a slash. Everything else keeps its quotes.

Does it minify the CSS and JavaScript inside the page?

No, those blocks are left exactly as they are. Use the CSS minifier and JavaScript minifier for that, then paste the result back.

Is my code uploaded anywhere?

No. The minifier runs in your browser, so you can paste private templates safely.

More in Developer

All tools in this category: Developer ·Updated November 3, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.