HTML Minifier
Minify HTML online for free: strip comments and whitespace, drop optional tags, shorten attributes, and beautify minified HTML back into readable code. 100% in your browser, no signup.
Your result will appear here.
⚡ Minifying shrinks a page by removing comments, whitespace, optional end tags and redundant attribute characters, so the file downloads sooner and parses faster. The page still renders exactly the same. The contents of pre, textarea, script and style elements are never touched, and inline CSS and JavaScript are left as they are: shrink those with the CSS and JavaScript minifiers first.
🔒 Privacy: minifying and beautifying run locally in your browser. Your markup is never uploaded, stored or seen by anyone else.
More developer tools
How this calculator works
An HTML minifier shrinks a page by removing everything the browser does not need to render it: comments, indentation, line breaks and redundant characters. The page renders exactly the same, but the file is smaller, downloads sooner and parses faster, which matters most on slow mobile connections where every kilobyte delays the first paint. Paste your markup here, or upload an .html file, and the minified version appears instantly with the byte count before and after and the percentage you saved.
This minifier is a small scanner that understands HTML, not a blind text replacer. It removes comments, collapses whitespace, drops end tags the HTML spec says are optional, shortens boolean attributes like checked="checked" to checked, and removes attribute quotes only when the value is safe without them, so URLs keep their quotes. What it never touches is just as important: the contents of pre, textarea, script and style elements pass through verbatim, because whitespace inside a pre block is visible text and a stray character inside a script can break the page, and conditional comments for old Internet Explorer versions are kept. The space between two inline elements is also kept, because <b>Hello</b> <i>world</i> needs it to stay two words.
The beautify mode does the reverse: it turns a minified file back into indented, readable HTML, one block element per line, which is handy when you inherit a crushed template from a CMS export or a copied page source and need to read it. Inline CSS and JavaScript are left as they are, so run those through the CSS and JavaScript minifiers first if they need shrinking too. A build tool will usually save more on a full project, because it also handles linked files and source maps, but for a single page or snippet this tool is faster: no install, no config, no upload. Keep in mind that real transfer sizes will be smaller again once the server applies gzip or Brotli, so the percentage shown here is the raw saving before compression. Your markup never leaves your device.
