Skip to content

HTML Minifier

Strip comments and dead whitespace out of a page.

Quick Tool Overview

The HTML Minifier removes comments and collapses the whitespace a browser would collapse anyway, with pre, textarea, script and style content lifted out and put back untouched. Whitespace is only removed entirely between block-level tags, where it was never rendered — between inline tags a space is a word gap, and removing it joins words together.

What it does
Removes HTML comments and redundant whitespace
You give it
A page or a fragment of HTML
You get back
Minified HTML with before and after sizes
Best for
Trimming template output before it ships
SEO Tools Free, unlimited use No sign-up Runs in your browser

About the HTML Minifier

Paste a page and the minifier removes comments and collapses the whitespace a browser would collapse anyway. Anything inside pre, textarea, script and style is lifted out first and put back untouched, because whitespace in those places is not decoration.

The approach here is deliberately conservative. Collapsing a run of whitespace to a single space is exactly what the rendering engine does, so it cannot change how the page looks. Removing whitespace entirely is only done between block-level tags, where it was never rendered; between inline tags a space is a word gap, and removing it joins words together — which is how aggressive minifiers produce pages that read as though the spacebar broke. What this will not do is rewrite attributes, drop optional tags or shorten booleans, all of which save a little and need a careful look at the result.

Key features of the HTML Minifier

Protected regions

pre, textarea, script and style are lifted out before anything is collapsed and restored exactly.

Safe by construction

Collapsing to a single space is what the rendering engine does, so it cannot change the page.

Block-level gaps only

Whitespace is removed entirely only where it was never displayed in the first place.

Conditional comments kept

They are markup for old browsers, not commentary, so removing them removes behaviour.

Real size comparison

Raw and minified sizes with the percentage saved, so you can see whether it was worth it.

How to use the HTML Minifier

  1. 1

    Paste your HTML

    A full page or a fragment. Nothing is uploaded — the work happens in your browser.

  2. 2

    Choose how far to go

    Comments, whitespace collapsing and block-level tag gaps are separate options.

  3. 3

    Check the saving

    Before and after sizes are shown, with the percentage and the gzipped estimate.

  4. 4

    Copy or download

    Take the result, or download it as a file.

Frequently asked questions

The way this does it, yes. Collapsing whitespace to a single space is what the browser does when rendering, and whitespace between block-level tags was never displayed. Content inside pre, textarea, script and style is protected, so the risky cases are excluded rather than handled.

Reviews of the HTML Minifier

What people who use the HTML Minifier think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the HTML Minifier. It takes half a minute and no account.

Write the first review

More SEO tools