Skip to content

HTML Minifier

Minify HTML by removing comments, line breaks and whitespace between tags, and see how much smaller the markup becomes.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is HTML Minifier?

This HTML minifier makes HTML smaller by removing what browsers do not need to render it: comments (<!-- … -->), line breaks, indentation and the whitespace between tags. Smaller HTML downloads faster, which helps first-load performance on slow connections, and fits better where size limits apply.

Paste your markup and the minified version appears next to it with before and after character counts and the percentage saved, ready to copy into a template, an email or a static page.

How to use HTML Minifier

  1. Paste your HTML into the Raw HTML Input box.
  2. The minified HTML appears in the output box instantly.
  3. Check the character count and percentage saved.
  4. Preview the result in the HTML Viewer, then copy it.

Key features

  • Removes HTML comments
  • Deletes whitespace between tags
  • Collapses line breaks and indentation
  • Shows character counts and percentage saved
  • Instant output as you type
  • Runs entirely in your browser

Common use cases

  • Shrinking static HTML pages and landing pages
  • Minifying HTML email templates to stay under clipping limits (Gmail clips at about 102 KB)
  • Compressing HTML snippets stored in databases or JSON
  • Reducing the size of server-rendered templates
  • Quickly minifying markup without a build tool

Technical details & standards

Minification removes HTML comments, deletes whitespace between a closing > and the next <, and collapses any remaining runs of whitespace into a single space. Typical savings are 10–25% for indented markup.

Whitespace between inline elements is significant in HTML, so removing it can change the rendering: <b>Hello</b> <i>world</i> becomes <b>Hello</b><i>world</i> with no space between the words. Whitespace inside pre and textarea elements and inline scripts is also collapsed. Preview the result before using it, and keep conditional comments if you target old email clients. Attribute quotes, optional tags and inline CSS and JavaScript are left unchanged.

Frequently asked questions

Can minifying HTML break my page?

It can change spacing: whitespace between inline elements, such as two links or a bold word followed by an italic word, is removed, and text in pre blocks is collapsed. Preview the minified HTML to check.

How much does HTML minification save?

Typically 10–25% for indented markup with comments. Server-side gzip or Brotli compression saves considerably more and should be enabled as well.

Should I minify HTML emails?

Often yes: Gmail clips messages larger than about 102 KB, hiding the end of the email. Minifying a large template can keep it under that limit. Test the result in your email client.

Does it minify inline CSS and JavaScript?

Their whitespace is collapsed but they are not otherwise optimized. Use the CSS Minifier and JavaScript Minifier on those blocks separately.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More formatters & viewers tools

View all