HTML Minifier

Free HTML minifier. Compress HTML by stripping comments and whitespace between tags, while preserving the formatting inside <pre>, <textarea>, <script>, and <style>.

AI-ready Use this tool with AI

This tool has a free JSON API. Copy a prompt or skill below to use it with ChatGPT, Claude, or any AI agent — no API key needed.

API docs
Paste your HTML above.

How html minifier works

HTML minification shrinks a page by removing comments and the whitespace browsers do not need between tags. The minified page is functionally identical but smaller, so it downloads and renders faster, which improves page speed and Core Web Vitals.

This minifier removes <!-- ... --> comments, collapses runs of whitespace to a single space, and strips spaces around tag brackets. Crucially, it preserves the content of <pre>, <textarea>, <script>, and <style> blocks, where whitespace and line breaks are significant and removing them would change the output.

Paste your HTML and click Minify. The tool reports the original size, the minified size, and the saving in bytes and as a percentage. For a full production pipeline you may also want to minify inline CSS and JS (use the CSS and JavaScript Minifier tools) and gzip the output on the server.

Frequently asked questions

What does minification remove?
Comments and unnecessary whitespace between tags. Spaces around < and > are removed, and runs of whitespace collapse to one space. Tag content is unchanged.
Will it break <pre> or <script> blocks?
No. Whitespace inside <pre>, <textarea>, <script>, and <style> is preserved exactly, because there it changes meaning. Only inter-tag whitespace is collapsed.
How much size can I save?
Typically 20 to 40 percent for hand-written HTML with indentation and comments. The exact saving is reported, and gzip on top gives the final transfer size.
Is this enough for production?
For most pages yes. Combine it with CSS and JavaScript minification for inline assets, plus gzip or Brotli compression on the server, for the biggest download savings.