Code Minifiers

HTML Minifier

Minify HTML, remove unnecessary whitespace and comments, and compare original size, result size, and savings.

Press Ctrl / ⌘ + Enter to run
Read-only result

Minify HTML, remove unnecessary whitespace and comments, and compare original size, result size, and savings.

What this tool does

Minify HTML while keeping whitespace that affects how text is displayed and preserving the formatting inside pre and textarea. This reduces the document size without joining words that should stay separate.

  • Ordinary comments are removed, while conditional comments are preserved.
  • Text and whitespace that need to remain inside pre, textarea, script, and style are preserved.
  • Embedded CSS and JavaScript are not minified further, and your code is not executed.

How to use it

  1. Remove ordinary comments while preserving conditional comments.
  2. Click "Compress HTML."
  3. Embedded CSS and JavaScript are not additionally minified, and your code is not run.
  4. Copy or download minified.html and test the page in your project.

Common uses

  • Reduce the deployment size of static pages.
  • Compare development vs. release HTML.
  • Remove safely removable comments and redundant attributes.

HTML Minifier Features

Reduce unnecessary content in HTML while keeping preformatted text and essential whitespace. Compare the original and compressed sizes and the savings, then copy or download the result.

FAQ

Why can't you just remove all whitespace?

Whitespace between inline elements affects visible text, and pre/textareas are also left blank; global replacement breaks content.

Will the code in script and style be compressed?

The current configuration does not additionally minify inline JS/CSS and just lets the HTML minifier safely handle element boundaries.

Can the compression result directly replace the source code?

Keep the original file. Check how the minified result displays where you plan to use it, especially if the content includes special template syntax.

Back to Developer Tools