HTML Minifier

Client-sideNo sign-upFree

Strip comments and collapse whitespace in HTML to shrink file size before shipping it.

How this tool works

1

Paste your HTML

Any well-formed markup, including inline scripts and styles.

2

Comments and whitespace are stripped

HTML comments are removed and the whitespace between tags is collapsed.

3

Compare the size reduction

Before/after byte counts and a percentage show exactly how much smaller the file gets.

4

Copy the minified output

Grab the compacted markup, ready to ship to production.

Quick facts

Category
Formatters & Beautifiers
Best for
Shrinking page weight before deploying to production
Input
220 bytes before
Minified output
<!DOCTYPE html><html><head><title>Formatiq</title></head><body><h1>Hello, world!</h1><p>This is a sample paragraph with extra spaces.</p></body></html>
151 bytes after - 31.4% smaller
In-content slot

About this tool

Paste HTML and get a compacted version with comments removed and the whitespace between tags collapsed, so indentation and line breaks used for readability during development don’t ship to production. The before/after byte counts and percentage reduction make it easy to see exactly how much a given page shrinks. This is a lightweight, whitespace-and-comment-only minifier rather than a full HTML parser - it won’t restructure tags, dedupe attributes, or rewrite inline scripts and styles, so it’s safe to run on any well-formed markup without risking a broken layout. Everything runs client-side.

Why use this tool

Visible size savings

Before/after byte counts and a percentage reduction, not just a smaller-looking block of text.

Safe on real markup

Only touches comments and whitespace - attribute values and script/style content stay intact.

No build step required

Minify a snippet or full page without setting up a bundler or build pipeline.

Un-minify companion available

Pair with the HTML Formatter when you need to go the other direction and read minified markup.

Frequently asked questions

It only removes HTML comments and collapses whitespace sitting between tags - it doesn’t touch attribute values, inline script or style content, or reorder anything, so layout and behavior stay intact. The one thing to watch for is inline elements where whitespace is visually significant (like text spacing between two <span> tags), since collapsing that whitespace can visibly join words that were meant to have a space between them.

It compares the byte size of your input to the byte size of the minified output using the same measurement a server would use for Content-Length, so the percentage reflects the real bandwidth savings from serving the minified version instead of the original.

Explore more free tools

Formatters, converters, validators, and generators - all free and running entirely in your browser.

Browse more tools