HTML Minifier
Minify HTML in your browser by reducing unnecessary whitespace and formatting while keeping the markup usable.
Your result will appear here.
HTML Minifier online
Minify HTML by removing comments and collapsing the whitespace between tags — a smaller document with the same DOM — for hand-maintained pages and embedded markup.
How to use this tool
- Paste your HTML into the input box.
- Click Minify. Comments are stripped, gaps between tags are closed, and runs of whitespace collapse to single spaces.
- Copy the minified HTML from the result panel.
Common uses
Shrinking a hand-written landing page before upload, compressing HTML email templates toward client size limits, embedding markup in a JSON payload, and auditing how much of a page's weight is formatting rather than content.
How it works
Three textual passes do the work: HTML comments are deleted, whitespace sitting directly between a closing and opening bracket (> <) is removed entirely, and any remaining run of two or more whitespace characters becomes one space. Attribute values, text content and tag structure are otherwise untouched, and no optional tags are omitted — the output stays the same document, minus its air.
Worked example
The fragment
<!-- nav --> <ul> <li>One</li> <li>Two</li> </ul>
minifies to <ul><li>One</li><li>Two</li></ul> — the comment and every inter-tag gap are gone, while the text inside the items keeps its shape.
Privacy and browser processing
Your HTML is minified in your browser with JavaScript — it is never uploaded or stored.
Frequently asked questions
Is it safe for pages with or
Be careful: the whitespace collapse applies everywhere, including inside preformatted blocks and textareas, where spaces are content. Minify templates without preformatted sections, or restore those blocks afterwards.
Can removing space between tags change rendering?
Between block elements, no. Between inline elements, the removed gap was sometimes a rendered space — two s that sat side by side with a visible space will touch after minifying. Check inline groups visually after minifying.
Does it minify the CSS and JavaScript inside the page?
No — style and script contents are treated as text. Their whitespace collapses to single spaces but they are not minified as code; use the CSS and JavaScript minifiers here for those assets separately.
Why keep the readable version?
Minified HTML is a deployment artifact. Edits belong in the readable source, then re-minify — hand-editing the squeezed version invites exactly the nesting errors the formatter exists to reveal.
Is my markup uploaded?
No. Minification runs in your browser; nothing is sent anywhere.