HTML Minifier

Strip comments and line breaks from HTML to shrink it, with four options to switch on and off.

0
Original Size (bytes)
0
Minified Size (bytes)
0%
Reduction

The minifier removes comments, indentation and line breaks that a browser never draws, then reports the size before and after in UTF-8 bytes. The code stays in the page. Korean characters take 3 bytes each, so deleting a Korean comment saves a lot.

This snippet is 81 bytes. Turning options on one by one gives:

<p title="note">
  <!-- hint -->
  <input type="checkbox" checked="checked">
</p>
Options onResultSize
Remove Comments, Remove Whitespace (default)<p title="note"><input type="checkbox" checked="checked"></p>61 bytes
plus Remove Unnecessary Quotes<p title=note><input type=checkbox checked=checked></p>55 bytes
plus Optimize Boolean Attrs<p title=note><input type=checkbox checked></p>47 bytes (42% smaller)

Quotes are dropped only when the value is letters, digits, - or _; title="About us" and href="/about" keep them. Boolean optimization strips ="checked", ="true" and ="" from 13 attributes such as disabled, checked and hidden.

What it leaves alone

The insides of <pre>, <code>, <textarea>, <script> and <style> are untouched, which means scripts and styles are not shortened either. Minify them with the JavaScript minifier or the CSS one first, then paste. Elsewhere, line breaks and runs of spaces collapse to one space, and spaces around block tags like <div>, <li> and <br> are removed. Only conditional comments starting <!--[if survive.

So a gap between <li> items set to display: inline-block disappears; use margin or gap instead. If your server sends gzip or brotli, the real transfer saving is much smaller than the percentage shown. Download saves index.min.html.