HTML Compressor
Paste HTML and get a minified version with comments removed, whitespace collapsed, and optional tags stripped — with a live byte savings count.
Last updated: May 26, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is HTML Compressor?
HTML minification reduces page weight by removing content that is irrelevant to the browser's rendering: comments, extra whitespace between tags, empty attributes, and optional closing tags. The result is functionally identical HTML that loads faster.
Unlike JavaScript minification, HTML compression is conservative — it must not change the rendered output. Script, style, pre, and textarea contents are never touched. Only inter-tag whitespace is collapsed, and IE conditional comments are preserved.
How to Use HTML Compressor
Paste HTML into the input panel.
Toggle the compression options you want.
The compressed output appears on the right with the reduction percentage.
Copy the output.
Common Use Cases
- Reducing HTML file size for faster page loads.
- Stripping developer comments before deploying to production.
- Removing unnecessary whitespace from templated HTML output.
- Pre-processing HTML before putting it into a CDN or cache.
Example Input and Output
A typical HTML document with comments and whitespace is compressed.
<!DOCTYPE html>
<html>
<!-- Page header -->
<head><title> Hello </title></head>
<body>
<h1> World </h1>
</body>
</html><!DOCTYPE html><html><head><title> Hello </title></head><body><h1> World </h1></body></html>Privacy
All compression happens in your browser. No HTML is sent to a server.
IE Conditional Comments
Comments starting with <!--[if are IE conditional comments and are preserved even when "Remove comments" is enabled, since they control IE-specific rendering.
Frequently Asked Questions
Is compressed HTML still valid?
Yes — the compression removes content that has no effect on rendering. The browser sees the same document structure.
Why are script and style contents preserved?
Whitespace inside script and style blocks is semantically significant (e.g., regular expressions, multi-line strings). Compressing them requires a separate JS/CSS minifier.
What are optional tags?
HTML5 allows certain tags to be omitted: the opening and closing <html>, <head>, <body> tags, and <tbody>. Removing them saves a few bytes but can confuse some older parsers.
Does this send my HTML anywhere?
No. All compression happens locally in your browser.
Related Tools
HTML Beautifier
Format and beautify minified or messy HTML code.
HTML Cleaner
Clean messy HTML by removing inline styles, scripts, comments, empty tags, Word markup, class and data attributes.
HTML Minifier
Compress HTML by removing whitespace, comments, and redundant attributes — with size reduction stats.
CSS Minifier
Compress and minify CSS code to reduce file size and speed up page loads.
JavaScript Minifier
Compress and minify JavaScript using Terser — with variable mangling, dead-code removal, and size stats.
HTML Stripper
Remove HTML tags from text, preserving line breaks and decoding HTML entities. Instant plain-text extraction from HTML.

