HTML Minifier
Minify and compress HTML by removing comments and extra whitespace, while keeping content inside pre, textarea, script, and style tags intact.
ToolsSoup's HTML Minifier is a free online tool that compresses HTML to the smallest possible size right in your browser. It strips out comments, collapses runs of spaces, tabs, and line breaks, and removes the whitespace between tags — then shows exactly how many bytes you saved. Content inside pre, textarea, script, and style tags is left untouched, and conditional comments are preserved. Nothing is uploaded, so even private markup stays on your own device.
What is an HTML minifier?
An HTML minifier compresses a web page's markup by removing everything a browser does not need to render it: indentation, blank lines, the whitespace between tags, repeated spaces, and HTML comments. The result is markup that is functionally identical to the original but takes up far fewer bytes. It is the opposite of an HTML beautifier — instead of spreading the markup across many readable, indented lines, it squeezes it down for faster downloads and smaller files.
How to minify HTML online
Compressing HTML with ToolsSoup takes just a couple of clicks:
- Paste your HTML into the input box on the left.
- Click Minify to strip comments and collapse the whitespace between and inside your tags.
- Check the savings summary to see the original size, minified size, and how many bytes you saved.
- Copy the compact result with one click and drop it straight into your page or build output.
What does the HTML minifier preserve?
The minifier is careful to only remove whitespace that does not affect how the page renders. The text inside pre and textarea elements keeps its exact spacing and line breaks, because that whitespace is significant. JavaScript inside script tags and CSS inside style tags is passed through unchanged so nothing breaks. Internet Explorer conditional comments are kept as well, since browsers still rely on them. Everything else — page comments, indentation, and the gaps between tags — is compressed away.
Why minify HTML?
Smaller HTML downloads faster, which improves page-load time and Core Web Vitals, and it lowers bandwidth for both you and your visitors. Removing comments before deploying keeps internal notes out of production. Minified markup is also handy to embed as a one-line string inside email templates, JSON payloads, or generated documents where extra whitespace would only add noise.
Why use this HTML minifier?
- 100% free with no ads, sign-up, or usage limits.
- Runs entirely in your browser — your markup is never uploaded to a server.
- Removes comments and collapses all extra whitespace in one click.
- Keeps pre, textarea, script, and style content byte-for-byte intact.
- Preserves IE conditional comments so nothing breaks.
- Shows byte savings so you can see how much smaller the page got.
- Works offline once the page has loaded.
Frequently asked questions
Is this HTML minifier free?
Yes. Every tool on ToolsSoup is completely free to use, with no account, sign-up, or hidden limits.
Is my HTML safe?
Absolutely. All minifying happens locally in your browser using JavaScript, so your markup is never sent to or stored on any server.
Will minifying break my page layout?
No. The minifier only removes whitespace that browsers ignore and HTML comments. Whitespace inside pre and textarea elements — where spacing is meaningful — is preserved exactly, so your layout renders the same.
Does it touch my inline JavaScript or CSS?
No. Content inside script and style tags is passed through unchanged. The minifier compresses the surrounding markup but never rewrites your JavaScript or CSS, so nothing functional is altered.
Does it remove HTML comments?
Yes. Regular comments are stripped to save bytes. Internet Explorer conditional comments are kept, however, because some browsers still depend on them to load specific markup.
How much smaller will my HTML get?
It depends on how much indentation and how many comments the original has. Heavily formatted, commented pages can shrink noticeably. After each minify, the tool reports the original size, the new size, and the exact number of bytes saved.