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.

