HTML Minifier

Paste HTML and get a smaller version with comments and extra whitespace removed. The minifier is careful: a single space stays between inline elements so words don't run together, and the contents of pre, textarea, script and style are left exactly as written. You see how many bytes you saved and can copy the result or download it as a file. Everything runs in your browser.

<!--[if IE]> blocks

Smaller, but can join words split across tags like <b> and <i>

301 bytes225 bytesSaved 76 bytes (25.2%)

Minifying runs in your browser. What you type never leaves this device.

Features

  • Removes HTML comments; keeps IE conditional comments if you want

  • Collapses runs of spaces, tabs and new lines

  • Drops whitespace next to block elements like div, p and li

  • Keeps one space between inline elements, so text reads the same

  • Tidies spaces inside tags without touching quoted attribute values

  • Leaves pre, textarea, script and style contents unchanged

  • Shows bytes before and after; copy or download

  • Runs in your browser: your code is never uploaded

When to minify HTML

Email templates

Some email clients clip messages above a size limit; a smaller template is less likely to be cut off.

Static pages and landing pages

Shave bytes off hand-written pages served without a build step.

Embeds and snippets

Shrink a widget or banner snippet before pasting it into a CMS field with a length limit.

What the minifier changes, and what it doesn't

Safe by default

Browsers ignore whitespace next to block elements, so removing it never changes the page. Between inline elements such as b, i, a and span, a space can be visible, so one space is kept. Turn on Remove all space between tags only if your layout doesn't rely on those spaces.

Left as written

  • pre and textarea, where whitespace is part of the content.
  • script and style blocks. Minify them separately with the JavaScript minifier and CSS minifier.
  • Attribute values in quotes, including spaces inside them.

Bigger savings

Most web servers also compress HTML with gzip or Brotli on the way to the browser, which saves far more than minifying. Minifying still helps for email templates, inline snippets and pages served without compression.

HTML Minifier - FAQ