Skip to content
ZeroServer.tools

HTML Minifier

Strip comments and whitespace from HTML to reduce file size.

Drop an HTML file or click to browseLoads it into the input below

Minification Settings

Compression Statistics

Original Size

623 B

Minified Size

404 B

Bytes Saved

219 B

Savings Ratio

35.2%

Minified (65%)Saved (35%)
-219 bytes (35.2%)
Output updated — 404 characters

Why minify HTML?

HTML minification reduces page weight by removing content that browsers don't need: all HTML comments, extra whitespace between tags, and blank lines. The markup remains functionally identical but downloads faster — especially noticeable on slow connections or large documents. This tool uses regex-based minification and removes all HTML comments without exception, collapses inter-tag whitespace to nothing, and squashes any remaining multi-space runs to a single space. All processing runs locally in your browser — nothing is sent to a server. Note: this is a lightweight approach suitable for most static HTML. Complex pages with inline scripts may require a dedicated build-tool minifier.

Related tools: CSS Minifier · HTML Formatter · Remove HTML Tags

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Checking how much a page's markup shrinks before adding a build step.
  • Producing compact markup for an inline template.
  • Stripping comments before publishing markup externally.
  • Checking whether a page's weight is markup or the assets it references.
  • Comparing two templates on size with formatting removed.

Frequently Asked Questions

Which whitespace is safe to remove?
Whitespace between block elements, but not between inline ones — collapsing the gap between two `<span>`s removes a rendered space. That distinction is why a naive minifier changes how a page looks.
Is minifying worth it with gzip enabled?
Marginally. Compression already handles repeated whitespace well, so the extra saving is usually a few percent. It matters most for pages served uncompressed or inlined into another document.
Are quotes around attributes removable?
Sometimes — HTML allows unquoted values with no spaces or special characters. It saves a few bytes and makes the markup fragile to edit, which is a poor trade outside a build step.
What about the content of pre and textarea?
It must be left exactly as-is, since whitespace there is significant. A minifier that collapses inside them visibly changes the page, which is why those elements are always excluded.
Should comments be stripped?
Ordinary ones yes, but conditional comments and any markers a framework relies on must survive. Server-side templating markers left in the output are another common casualty.

Common errors and gotchas

  • Removing whitespace between inline elements, which changes the rendered spacing visibly.
  • Collapsing whitespace inside `pre` or `textarea`, where it is significant.
  • Stripping a conditional comment or a build directive that was load-bearing.
  • Removing an optional closing tag that a fragile parser downstream actually needed.
  • Minifying a template with server-side tags, which a pure HTML parser may reorder.

Related Developer Utilities tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate