WebToolsPlanet
Developer Tools

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

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Paste HTML into the input panel.

2

Toggle the compression options you want.

3

The compressed output appears on the right with the reduction percentage.

4

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.

HTML input
<!DOCTYPE html>
<html>
  <!-- Page header -->
  <head><title>  Hello  </title></head>
  <body>
    <h1>  World  </h1>
  </body>
</html>
Compressed output
<!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.