Free Online HTML Minifier
This minifier removes HTML comments and the extra spaces and line breaks between tags to reduce file size. It is deliberately conservative so the page still renders the same.
Every extra space and comment in an HTML file is a byte the visitor's browser must download. Developers shrink a landing page, an email template or a static snippet before pasting it into a CMS field that has a size limit. Others use it to strip developer comments before sending markup to a client. It is also handy for turning a nicely indented fragment into a single line to store in a JSON string or a data attribute. The page is intended for small to medium fragments, not entire build pipelines.
Paste your markup into the box labelled Input, where a short sample with a comment and extra spaces is already waiting. The Result panel shows the compact version immediately, and underneath it a line reports the saving in the form of old length to new length in characters with a percentage. Press the copy button to take the output. There are no options to set. The tool removes comments, collapses runs of whitespace to one space, and deletes whitespace that sits between a closing and opening tag.
Contents of pre, textarea, script and style elements are set aside before minifying and restored unchanged, so code samples and inline scripts keep their formatting. Conditional comments of the old Internet Explorer type are also kept. The trade-off is that whitespace between two inline tags disappears: a space between a closing bold tag and an opening italic tag will vanish, and two words can end up joined. Attribute quotes and optional tags are not touched, so savings are modest compared with aggressive minifiers. Always preview the result in a browser.
The sample input is a div containing a comment and a paragraph reading Hi there with odd spacing. It is 53 characters long, and the minified output is <div><p> Hi there </p></div>, which is 28 characters, a saving of 47 percent. The single spaces inside the paragraph remain because they sit next to text, not between tags. Small files shrink by a larger share than large ones do, but the real-world gain for a whole page is usually a few percent, and server compression such as gzip matters more.
Key Highlights:
- Free to use, no signup
- Instant results
- Processed in your browser
- Works on mobile and desktop

