HTML Minifier

Minify HTML in your browser by reducing unnecessary whitespace and formatting while keeping the markup usable.

Ad space — place your AdSense unit here after approval.
Note: this is a pattern-based formatter. Check string literals, template literals and regular expressions in the output before using it in production.
Your result will appear here.

HTML Minifier online

Minify HTML by removing comments and collapsing the whitespace between tags — a smaller document with the same DOM — for hand-maintained pages and embedded markup.

Quick answer: Minify HTML in your browser by reducing unnecessary whitespace and formatting while keeping the markup usable.

How to use this tool

  1. Paste your HTML into the input box.
  2. Click Minify. Comments are stripped, gaps between tags are closed, and runs of whitespace collapse to single spaces.
  3. Copy the minified HTML from the result panel.

Common uses

Shrinking a hand-written landing page before upload, compressing HTML email templates toward client size limits, embedding markup in a JSON payload, and auditing how much of a page's weight is formatting rather than content.

How it works

Three textual passes do the work: HTML comments are deleted, whitespace sitting directly between a closing and opening bracket (> <) is removed entirely, and any remaining run of two or more whitespace characters becomes one space. Attribute values, text content and tag structure are otherwise untouched, and no optional tags are omitted — the output stays the same document, minus its air.

Worked example

The fragment

<!-- nav -->
<ul>
  <li>One</li>
  <li>Two</li>
</ul>

minifies to <ul><li>One</li><li>Two</li></ul> — the comment and every inter-tag gap are gone, while the text inside the items keeps its shape.

Privacy and browser processing

Your HTML is minified in your browser with JavaScript — it is never uploaded or stored.

Frequently asked questions

Is it safe for pages with
 or