HTML Minifier
Shrink your HTML by stripping comments and collapsing whitespace, while keeping <pre>, <textarea>, <script>, and <style> content exactly as written. It all runs in your browser, so your code is never uploaded.
Why This Tool Matters
HTML is usually the first thing a browser has to download, and every byte of indentation and leftover comment delays it. A developer hand-writing a landing page wants to ship it without the "TODO: replace hero image" notes. A marketer pasting an email template into a CMS field with a strict size limit needs it smaller right now. Someone embedding a widget snippet on a page wants it compact so it doesn't bloat the host document. Seeing the exact before and after size makes the saving concrete, and on template-heavy pages it is often 10 to 30 percent of the markup.
What makes naive minifiers risky is whitespace that matters: a code sample in a <pre> block, text in a <textarea>, or the space between two inline elements. This tool leaves the first two untouched and collapses the last to a single space, so the page looks the same. It is a quick, private way to minify HTML before launch; for a full build pipeline, run a minifier there as well.
How to Use
- 01
Paste your HTML
Drop in a full page or a fragment — the minified result appears as you type.
- 02
Choose about comments
Leave "Remove HTML comments" on to strip them, or switch it off to keep them.
- 03
Check the savings and copy
Compare original and minified size, then copy the output.
More Text Tools
Frequently Asked Questions
Is it safe to use this minified HTML in production?
For most pages, yes. The minifier only removes comments and redundant whitespace, never tags, attributes, or text, and it leaves <pre>, <textarea>, <script>, and <style> blocks exactly as written. The one judgment call is whitespace between inline elements, such as <b>a</b> <i>b</i>: it is collapsed to a single space rather than removed, so the rendering stays the same. Still, compare the page before and after, and keep your readable source file; minify as a final build step.
Does it minify inline CSS and JavaScript?
No. Contents of <style> and <script> tags are deliberately left untouched, so a comment or newline in your JavaScript can never be misread and break the code. This tool only minifies the HTML markup itself. If you want smaller CSS or JS as well, run those through a dedicated CSS or JavaScript minifier first, then paste the finished HTML here.
Are conditional comments kept?
Yes. Old Internet Explorer conditional comments like <!--[if IE]>…<![endif]--> change how a page behaves, so they are kept even when "Remove HTML comments" is on. Ordinary comments are removed. Turn the option off to keep every comment.
What is the difference between minifying and beautifying HTML?
They are opposites. Minifying strips whitespace and comments to make the file smaller for faster downloads, at the cost of readability. Beautifying adds line breaks and indentation so people can read and edit it. Minified HTML is meant for the browser, beautified HTML for you. This tool only minifies.
Is my code uploaded to a server?
No. The minification runs as JavaScript in your browser, so your HTML is never sent, logged, or stored anywhere. That makes it safe for unreleased pages, internal templates, or markup with private details, and it keeps working offline once the page has loaded.