Free developer tool

HTML Minifier

Shrink HTML safely: remove comments and collapsible whitespace, and minify inline CSS, JavaScript and JSON-LD.
Options

A careful HTML minifier

Most of the size savings in HTML come from three places: comments, indentation and inline scripts or styles. This tool removes comments (except conditional comments), collapses runs of whitespace to a single space, drops whitespace next to block-level tags where browsers ignore it anyway, and can minify inline <style>, <script> and JSON-LD blocks.

It's deliberately conservative. Content inside <pre>, <textarea>, <script> and <style> is never collapsed, attribute values are left exactly as written, and the single space between inline elements like links and bold text is kept, so the page reads the same.

What it doesn't do

  • It doesn't remove optional tags or attribute quotes. Those save a few bytes but make the HTML harder to work with.
  • It can't see your CSS, so elements styled with white-space: pre can lose spacing. Check those pages.
  • A broken inline script is kept as-is, and you'll see a warning.

Frequently asked questions

Should I minify HTML if my server already uses gzip or Brotli?
Compression already removes most of the repetition, so the gain is smaller, usually a few percent. It still helps on large pages and inline scripts, and it reduces the work the browser does parsing.
Will minifying HTML affect SEO?
Not directly. Search engines read minified HTML the same way. Faster pages can help Core Web Vitals, but content, titles and links matter far more.
Is my HTML uploaded?
No. The minifier runs in your browser and nothing is sent to a server.