HTML Minifier
Free online HTML minifier. Compress your HTML in the browser by collapsing whitespace between tags and stripping comments to reduce page size and load faster. Content inside <pre> and <textarea> is preserved. Nothing is uploaded.
How to use the HTML Minifier
- 1Paste your HTML into the input box, or upload an .html file using the file picker.
- 2If the tool offers toggles, choose whether to remove comments and whether to collapse whitespace between tags (both are typically on by default).
- 3Click the Minify button to compress the markup instantly in your browser.
- 4Review the output panel, where you can usually see the original versus minified byte size and the percentage saved.
- 5Click Copy to grab the minified HTML, or Download to save it as a new .html file.
- 6Keep your original formatted file as the source you edit, and use the minified version only for deployment or export.
About the HTML Minifier
HTML Minifier strips the dead weight out of your markup right inside your browser tab. When you paste a page into it, the tool walks through your HTML and collapses the runs of whitespace that sit between tags, the indentation, line breaks, and padded spaces that make source readable for humans but mean nothing to a browser. It also removes HTML comments, including the leftover TODO notes, commented-out blocks, and build annotations that quietly ship to every visitor. The result is byte-for-byte identical output for the rendered page, just smaller and faster to transfer.
The processing happens entirely client-side in JavaScript. Your markup never leaves the machine you are on, nothing is uploaded to a server, and there is no round trip, so you can safely minify internal admin templates, unreleased landing pages, or client work without exposing anything. Because it runs locally it is instant even on large files, and it works offline once the page has loaded.
Two things are deliberately left untouched. Content inside pre tags and textarea elements is preserved exactly as written, whitespace and all, because in those elements spacing and line breaks are meaningful and collapsing them would visibly break code samples, ASCII layouts, or pre-filled form values.
The practical payoff is smaller HTML documents. For a content-heavy page, trimming indentation and comments commonly shaves 10 to 25 percent off the raw file size before gzip, which lowers bandwidth, speeds up first paint, and helps on mobile connections. It is handy when your framework or CMS emits nicely formatted but bloated HTML, when you are hand-optimizing a static site, when preparing email HTML where every kilobyte counts, or when you just want to inspect how much filler a template carries. Developers, static-site builders, email marketers, and anyone doing front-end performance work benefit. A good habit is to minify as a final export step and keep your readable formatted version as the source you actually edit, since minified HTML is hard to work with by hand.
Frequently asked questions
Will minifying change how my page looks or behaves?
No. The tool only removes whitespace that browsers ignore anyway and strips comments, which never render. The DOM the browser builds is identical, so your page looks and behaves exactly the same, just from a smaller file.
Why is the whitespace inside my pre and code blocks not being removed?
That is intentional. Whitespace inside pre and textarea elements is significant, meaning line breaks and spaces actually display on the page. The minifier deliberately preserves those elements untouched so your code samples and preformatted layouts do not collapse into one line.
Is it safe to minify private or unreleased HTML here?
Yes. Everything runs client-side in your own browser with JavaScript. Your markup is never uploaded or sent to any server, so internal templates, client work, and draft pages stay entirely on your machine.
How much smaller will my file get?
It depends on how much indentation and how many comments your HTML carries. Nicely formatted, comment-heavy pages often drop 10 to 25 percent in raw size. If your HTML is already compact, the savings will be smaller. Note that gzip on your server compresses further on top of minification.
Should I minify inline CSS and JavaScript with this too?
This tool focuses on HTML structure: whitespace between tags and HTML comments. It does not deeply compress the contents of style or script blocks the way a dedicated CSS or JS minifier would. For best results, minify your CSS and JavaScript with tools built for those languages, then minify the HTML shell here.
Related tools
Browse all free online tools in Text tools and more.
Frequently asked questions
Is this HTML minifier free and private?+
Yes. Minification happens locally in your browser — your HTML is never uploaded, with no limits or watermarks.
Will it break my page content?+
No. It uses a conservative approach: comments are removed and whitespace is collapsed, but content inside <pre> and <textarea> tags is left exactly as written.
What does it strip out?+
It removes HTML comments and collapses runs of whitespace, including the whitespace between adjacent tags, while showing how much size you saved.