HTML Minifier

Shrink HTML safely: strip comments and redundant whitespace, drop default type attributes and quotes — script, style and pre stay untouched.

Minification happens locally in your browser. Your HTML never leaves your device.

Whitespace
—

How It Works

The page is scanned once, separating raw regions (script, style, textarea and pre blocks pass through byte-for-byte) from ordinary markup. In markup, comments are dropped unless they are conditional, whitespace is collapsed, and — if enabled — attribute quotes that carry no risk come off and redundant default type attributes disappear. The transformations below are the whole list; nothing else is attempted.

Safe here, safe there, and why the line is drawn
Collapse whitespace between tags: safe, except around pre/textarea/script where it is content, which the raw-region pass protects. Remove comments: safe, except conditional ones that old IE executes. Drop quotes on plain values like class="box": safe by HTML5 rules. Those three run here. Removing optional end tags (</p>, </li>) is deliberately NOT offered: browsers re-infer structure from context, and one misjudged nesting turns a layout upside down for a few bytes.
Conservative by design — and what it skips
This is a markup shrinker, not a build pipeline. It does not minify JavaScript or CSS (inline or external), does not shorten class names, does not touch URLs and does not inline or deduplicate anything. The npm html-minifier-terser goes further by bundling a real JS/CSS minifier; you do not need its output today, our Code Minifier page handles JS and CSS as its own job.
Preview before you ship
Whitespace between inline-block elements is visually meaningful, so Aggressive mode can close tiny gaps in rendering — that is why Safe mode (collapse to a single space) is the default and the stats line shows you exactly how many bytes each mode saves. If aggressive gains only a few hundred bytes over safe, keep safe.

Frequently Asked Questions

Does it also minify the JavaScript inside my script tags?

No. Script and style contents pass through byte-for-byte untouched. Real JS minification means parsing the language and renaming variables, which can change program behavior if done wrong — that is a different job with different tooling. Our sibling Code Minifier tool on this site does exactly that as a separate page.

What about the inline style attributes and style blocks?

Also untouched. Rebuilding CSS (merging rules, shortening colors) can alter cascade order in edge cases, so this tool leaves every style block and style attribute as written. Only the whitespace between HTML tags and in the markup itself is processed.

Why is comment removal optional, and what are conditional comments?

Ordinary HTML comments are dead weight in production, so they go by default. But legacy conditional comments — <!--[if IE]> ... <![endif]--> — are executable instructions for old Internet Explorer, and deleting them can change what those browsers render. The Keep conditional comments toggle preserves exactly that family of comments.

How much smaller will my file get?

Typical hand-written or template-generated HTML sheds roughly 5–15%: mostly indentation whitespace and comments. Minification frameworks that also shrink JS and CSS report bigger numbers, but they are doing more dangerous work. Check the stats line — if the gain is small on your file, the safe mode kept you out of trouble for nothing.

Is anything uploaded to a server?

No. The whole transformation is a regex-pass over your text in plain JavaScript inside the browser. Nothing is sent anywhere, and there is no account or network request attached to minifying.