Developer Tools

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.

Frequently asked questions

How do I minify HTML online?
Paste your HTML into the input box, or upload an .html or .htm file. The minified version appears instantly, with the byte count before and after and the percentage saved. Copy the result or download it as page.min.html. Nothing is uploaded: minifying runs in your browser.
Will minifying break my page?
No. The minifier only removes things a browser does not need to render the page: comments, whitespace between block-level tags, optional end tags, and redundant attribute characters. The contents of pre, textarea, script and style elements are preserved verbatim, and the space between two inline elements is kept so words never join. Always test the output in a browser before replacing a live file, especially for HTML emails, where some older clients are sensitive to whitespace.
What exactly does the minifier remove?
Comments (except conditional comments), whitespace and line breaks between block-level tags, optional end tags like </html>, </head>, </body>, </p> and </li> where the spec allows, quotes on attribute values that are safe without them, and boolean attribute values (checked="checked" becomes checked). Each step can be toggled off.
What is the difference between minifying and beautifying?
Minifying removes comments, whitespace and redundant characters so the file is as small as possible for transfer. Beautifying adds line breaks and indentation so minified HTML is easy to read and edit. Both keep the page identical: only the whitespace and formatting change.
Does it minify the CSS and JavaScript inside my page?
No. The contents of style and script elements are preserved exactly as written, because changing them blindly can break a page. To shrink them, run the CSS through the CSS Minifier and the JavaScript through the JavaScript Minifier, then paste the results back into your page.
Is my HTML uploaded anywhere?
No. Minifying and beautifying run locally in your browser. Your markup is never uploaded, stored or seen by anyone else, which makes the tool safe for unreleased pages and templates, though you should still avoid pasting live secrets anywhere you do not have to.
Disclaimer: Results are estimates for planning purposes only and are not financial advice. Actual loan terms, taxes and investment returns vary. Consult a qualified professional before making financial decisions.