consolelog.tools

HTML Minifier

Minify HTML live — strips comments and collapses whitespace while preserving <pre>, <textarea>, <script> and <style> contents verbatim.

About this ToolHow it works, benefits & use cases

Trim HTML down for production while keeping the parts that must stay byte-for-byte intact. This HTML minifier uses a raw-text-aware scanner: it first stashes the contents of <pre>, <textarea>, <script>, and <style> so they are immune to the cleanup, then strips comments (preserving IE conditional comments like <!--[if ...]-->), collapses whitespace between tags, and squeezes runs of multiple spaces down to one. Finally it restores the protected regions exactly as they were, so preformatted text, inline scripts, and styles never lose their spacing. The minified output regenerates live as you type, the output panel shows the new byte size and savings percentage, and a stats line reports original bytes, minified bytes, bytes saved, and the percentage saved. Everything runs in your browser with no upload and no sign-up.

How to Use

  1. 1Paste your HTML into the input box, or click Load example to load a sample with comments, a <pre> block, and an inline script.
  2. 2The minified HTML regenerates live as you type — the output panel shows the byte count and savings percentage.
  3. 3Press Minify HTML to confirm the result and surface any error.
  4. 4Check the stats line for original, minified, and saved bytes plus the percentage saved.
  5. 5Copy the minified HTML, download it as minified.html, or share the URL with your input encoded in it.

Key Benefits

  • Raw-text-aware: <pre>, <textarea>, <script>, and <style> contents are preserved verbatim
  • Strips HTML comments while keeping IE conditional comments intact
  • Collapses inter-tag whitespace and squeezes multiple spaces to one
  • Reports original, minified, and saved bytes plus percentage saved
  • Live minification as you type, with a shareable URL
  • Byte sizes measured with UTF-8 encoding for real transfer-size accuracy
  • Runs entirely in-browser — your markup is never uploaded

Common Use Cases

  • Shrinking a static HTML page or template before deploying it
  • Minifying email HTML where every byte counts, without breaking <pre> blocks
  • Removing developer comments and excess whitespace from generated markup
  • Compressing an HTML fragment or widget for embedding
  • Measuring how much whitespace and comments inflate a page before shipping

0 characters · live

Paste HTML above to minify it live.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools