HubTools

HTML Minifier

Minify HTML by removing comments, collapsing whitespace, removing empty attributes, and optional closing tags. See size savings instantly.

What is HTML Minification?

HTML minification strips every byte from a markup document that doesn't affect how the browser renders it: comments, indentation, whitespace between tags, default attribute values, optional closing tags, and empty attributes. The output is byte-identical in behavior — the browser's parser treats minified and pretty-printed HTML the same way — but typically 10–25% smaller before gzip. Combined with brotli or gzip, you get another 5–15% reduction because compression is more efficient on already-compact text. HTML is the first byte the browser parses, so trimming it directly improves Time to First Byte and First Contentful Paint, especially on mobile networks. This minifier handles the full pass in your browser — paste markup, hit minify, copy the result. Pair it with the CSS Minifier and JavaScript Minifier for a full production build.
Input HTML
Minified Output
Original Size
0bytes
Minified Size
0bytes
Savings
0.0%
Options
Remove Comments
Collapse Whitespace
Remove Empty Attributes
Remove Optional Tags
Remove Quotes

How to use this tool

  1. 1
    Paste your HTML
    Drop a full document or fragment into the input editor. The minifier handles HTML5 syntax including SVG and inline scripts.
  2. 2
    Click Minify
    The output editor shows the compressed HTML instantly, along with original size, minified size, and percentage saved.
  3. 3
    Copy or download
    Use the Copy button to grab the minified output for your build pipeline, or Download to save as a .html file.

Frequently asked questions

What does HTML minification remove?
Comments, leading and trailing whitespace, redundant whitespace between tags, empty attributes (class=""), default attribute values like type="text" on inputs, and optional closing tags such as </li>, </p>, and </tr> where the HTML5 spec allows omission. Typical savings on hand-written HTML are 10–25% before gzip.