HTML Minifier

Minify HTML by removing comments and collapsing whitespace between tags with a simple minifier.

Try an example

Load a ready-made sample into this tool and run it. Every result you see is calculated live by the tool itself — nothing here is a pre-written answer.

Sample: input: <div> <p> Hello World </p> </div>

How to Use

  1. Paste HTML code.
  2. Click Run.
  3. Copy the smaller HTML.

What this HTML minifier does

This HTML minifier reduces page markup by removing HTML comments and collapsing the whitespace between tags with a simple minifier. Paste a page or fragment, run the tool, and copy the smaller HTML for your project. The tags, attributes and text content stay in place; what disappears is the spacing and commentary that browsers never needed to display the page.

When to minify HTML

Minified HTML is handy before publishing a static page, pasting markup into an email template or content system with size limits, or trimming a saved page down for storage. Work on a copy: once comments and spacing are gone, the markup is harder to read, debug and edit by hand.

Good to know

This is a simple minifier, and it plays safe: whitespace inside preformatted text and inline elements is preserved conservatively, so savings vary from page to page. It does not rewrite tags or attributes, and it will not fix invalid markup.

Frequently asked questions

What exactly gets removed from my HTML?

HTML comments are stripped out and runs of whitespace between tags are collapsed. Your elements, attributes and visible text are left as they are, so the page should render the same way it did before.

Why are my savings smaller than expected?

Some whitespace has to stay. Text inside preformatted blocks and spacing between inline elements can change how a page renders if removed, so the tool keeps it, and pages heavy in that content shrink less.

Can it minify part of a page?

Yes. You can paste a fragment, such as a single section or a component, instead of a whole document. The same comment removal and whitespace collapsing applies, and you copy out just the minified fragment.

How to use HTML Minifier

  1. Paste HTML code.
  2. Click Run.
  3. Copy the smaller HTML.

Limitations

This is a simple minifier: whitespace inside preformatted text and inline elements is preserved conservatively, so savings vary.

Browse all tools · More Developer Tools tools

Scroll to Top