Source HTML
paste or type · or drop a .html file
Minified

Why minify HTML?

HTML minification collapses the whitespace between tags that templating engines and hand-written markup tend to accumulate, strips comments, and removes redundant attributes (type="text/javascript" on a <script> tag, for example). The savings are smaller than CSS or JS, since most of an HTML document is content, not syntax, but it still trims a real amount off every response.

TypicalShrinks 10-20%
RemovesInter-tag whitespace, comments, redundant attributes
BonusEmbedded <style> and <script> blocks are minified too

How this minifier works

This tool runs html-minifier-terser in your browser. Beyond collapsing whitespace and stripping comments, it recursively minifies any inline <style> and <script> blocks it finds, using the same CSS and JS minification engines this site's other minifiers use.

That recursive step is the main reason to reach for a dedicated HTML minifier instead of a generic whitespace stripper: a hand-rolled regex will not touch the CSS or JS sitting inside a <style> or <script> tag, but this one does.

Before deploying minified HTML

Keep the unminified source in version control, collapsed HTML is unpleasant to read or diff. Minifying is a build step, not something you edit by hand.

Server-side templating and static site generators (Next.js, Astro, Eleventy, Jekyll) typically minify HTML output automatically in production mode. Use this tool for a quick check on a static snippet or exported page; wire minification into the build for anything larger.