Compress · Shrink · Copy
Minify HTML Online
Updated: June 2026
The whitespace that makes HTML readable also makes it bigger. Minifying removes the comments and the gaps between tags that a browser does not need, producing a smaller page that downloads and parses faster while rendering exactly the same.
Free · No upload · Instant in the browser
What HTML minification removes
Minifying strips HTML comments, removes whitespace-only gaps between block-level tags, and collapses runs of spaces and line breaks down to the minimum. The tags, attributes and visible text are untouched — only the formatting whitespace disappears. Because browsers ignore whitespace between block elements, the rendered page looks identical; it is simply lighter on the wire.
Elements where whitespace is meaningful, like <pre> and <textarea>, are preserved exactly so the page still displays what it should.
It minifies the CSS and JS inside too
A page is mostly markup, but its inline <style> and <script> blocks can be a large share of its weight. This minifier compresses those blocks with its CSS and JavaScript engines as it goes, so the whole document shrinks, not just the tags. The JavaScript is minified conservatively — line breaks that matter for automatic semicolon insertion are kept — so the page keeps working after compression.
Why minify HTML
- Smaller pages reach first paint sooner, which helps Core Web Vitals.
- Less markup means less to parse, a real win on slow devices.
- Minified HTML compresses further under gzip and Brotli.
- It is the production-ready form — keep readable HTML in your source and serve the minified copy.
How to minify HTML
Paste your page or fragment into the tool and switch to the Minify tab. The compressed markup appears on the right with the percentage saved, so you can see the benefit immediately. Copy it or download it as an .html file. When you need to read it again, the same tool beautifies the minified markup back into clean, nested code.
Local and private
Minifying runs entirely in your browser with JavaScript. Whatever your markup contains — draft content, internal links, template data — none of it is uploaded. You can verify it by minifying with the network tab open, or by going offline and watching the tool keep working. There is no server round-trip, so even a large page compresses the instant you paste it.
Frequently asked questions
How do I minify HTML?
Paste your HTML into the tool and switch to the Minify tab. Comments and whitespace are stripped and the compact markup appears, ready to copy or download.
Will minifying break my page?
No. Only formatting whitespace and comments are removed, and whitespace-sensitive elements like pre and textarea are preserved, so the page renders the same.
Does it minify inline CSS and JS?
Yes. Style blocks are compressed with the CSS minifier and script blocks with the JavaScript minifier, conservatively so the code keeps running.
Is my HTML uploaded anywhere?
No. Minifying runs locally in your browser. Nothing is sent to a server and the tool works offline once loaded.