My Tool Studio
Developer

HTML Minifier

Every byte of markup has to travel before the browser can paint anything, so a bloated template costs real milliseconds. Use this page to minify html before shipping: it strips comments, collapses runs of whitespace into single spaces, and removes the gaps around tags, while leaving everything inside pre, code, script, style, and textarea untouched. The result is an html compressor pass that typically trims 5 to 20 percent off a page, more if your templates carry heavy indentation and comment blocks. Paste your markup, click Minify, and the badge above the output shows exactly what percentage you saved.

Always freeNo sign upRuns in your browser
Output appears here...

How to use

01

Paste the markup

A landing page, an email template, or a fragment all work. Click Try sample to load a small page with a comment and a pre block to see what changes.

02

Press Minify

One click runs the whole minify html online pass. Comments disappear, whitespace collapses, and the green percentage badge reports how much smaller the output is.

03

Ship the compact version

Copy the output into your deploy or paste it over the original file. Nothing visual changes, since the removed characters were never rendered anyway.

Why HTML Minifier

Common questions

What does the minifier remove, and what does it keep?
It deletes HTML comments, collapses whitespace runs, and trims the space between tags, which also makes it handy as a way to remove comments from code online. It keeps IE conditional comments, leaves html attributes exactly as written, and never touches the contents of pre, code, script, style, or textarea elements.
Will my code samples inside pre tags get mangled?
No. Those five protected elements are lifted out before the whitespace pass and restored afterward, byte for byte. Your indented examples and inline scripts come through unchanged.
Does minifying delete the html space code for non-breaking spaces?
No. An   entity is content, not formatting, so the tool leaves it in place. What collapses are literal runs of spaces, tabs, and newlines between elements, which browsers already render as a single space at most.
Can it compress the CSS and JavaScript inside my HTML page?
Not deeply. Style and script blocks are preserved as-is so nothing breaks. For real savings there, extract them and use the CSS Minifier for minify css and the JS Minifier for javascript minify, then paste the results back before you compress html online.
How much smaller will my HTML get?
Typical pages drop 5 to 20 percent, and heavily commented or deeply indented templates can lose more. Gzip on your server shrinks things further, but minifying first still helps, because repeated whitespace compresses to something rather than nothing.
Could I edit markup here like an html notepad online?
No, it's a one-shot transform rather than an editor. Paste, minify, copy. If you want to tweak markup, do it in your editor first, then bring the finished version here to minify code before release.
Does it build a DOM like an html parser online would?
No, it works with careful text rules instead of a document tree, which keeps it fast and browser-only. The trade-off is that it won't fix broken markup or reorder anything, so feed it valid HTML.
Can I use it just as an online space remover?
Sure. If all you want is extra whitespace gone from markup, the Minify button does that on its own. For prose rather than HTML, a plain text cleanup tool suits better, since this one also tightens the spacing around angle brackets.

More Developer tools

View all