Every comment and indentation space in your HTML is a byte a visitor has to download. This HTML minifier strips HTML comments and collapses the whitespace that browsers do not need, then shows you the honest maths: size before, size after, and the percentage saved.
It is careful where care matters. The contents of <pre>, <textarea>, <script> and <style> blocks are protected byte-for-byte — minifying the spaces inside a code sample or a script would change what it does, so this tool never touches them. Everything runs locally in your browser.
What minification actually removes
Three things. Comments — everything inside <!-- ... --> is for humans; browsers ignore it, but visitors still download it. Whitespace runs — the newlines and indentation that make source code readable collapse, in normal HTML flow, to a single space or to nothing at all between block tags. Padding at the edges — leading and trailing blank space around the document. What minification does not do is change the document: same tags, same attributes, same text. A minified component renders identically to the original; it just travels lighter.
The protected blocks, and why they matter
Naive minifiers cause a classic bug: they squeeze the whole file as one string and corrupt the code inside it. A <pre> block is whitespace-significant — the spaces are the content. A <script> can contain the text "<!--" or comparisons like a < b that a careless cleaner mangles. This tool lifts those four block types out before cleaning and puts them back untouched, so the saving you see is real but the risk is not. It is the same reason the sample above keeps its formatting demo intact when you minify it.
Where minified HTML pays off
Email templates are the biggest win: some email clients clip messages over roughly 100 KB, and comment-heavy templates are common offenders. Embedded components — a widget, a banner, a third-party snippet pasted into a CMS — carry their author’s comments and formatting into every page that includes them. Static sites and landing pages gain a few percent for free. Be realistic about scale, though: on a typical page, gzip or Brotli compression already removes most whitespace redundancy, so minification is the last few percent, not a transformation. It stacks with compression; it does not replace it.
How to use it
Paste your HTML, click Minify, and read the three numbers. If the saving surprises you — very large or suspiciously zero — scan the output before shipping it. Then copy the result straight into your template. Because nothing is uploaded, you can safely minify markup that contains internal URLs or unreleased product names.
Frequently asked questions
Will minified HTML look different in the browser?
No — with one nuance. Whitespace between inline elements (links, spans, buttons in a row) can affect visual spacing in HTML, because a collapsed space is still a space. This tool reduces whitespace runs to a single space rather than deleting them inside text flow, which preserves that behaviour; it only removes the space entirely between a closing and opening tag.
Does it minify the CSS and JavaScript inside my HTML?
No, and deliberately: <style> and <script> contents are protected, because CSS and JavaScript need their own minifiers with language-aware rules. Run those blocks through a CSS or JS minifier separately, then minify the assembled HTML.
Is minification the same as compression?
No. Minification rewrites the source into a smaller equivalent text; compression (gzip, Brotli) encodes the bytes for transport and the browser restores them exactly. Use both.
Is my code uploaded?
No. The minifier is a few string operations in your browser tab. View source on this page if you want to confirm it.
Related tools
Versión en español: Minificador de HTML — Minifica HTML Online y Mira Cuánto Ahorras. You may also like: CSS Minifier — Minify CSS Online, Free and Instant.
Embed this tool on your website — free
Copy the code below to add this working tool to your own page. A small credit link stays with it — that’s all we ask.
