HTML Minifier/Beautifier
Minify or pretty-print HTML with size comparison.
Examples
| Input | Result |
|---|---|
| <div> <p> Hello </p> </div> | <div><p>Hello</p></div> |
| <!-- nav --> <nav class="main"> </nav> | <nav class="main"></nav> |
| <div><span>A</span><span>B</span></div> (minified) | <div> <span>A</span> <span>B</span> </div> (pretty) |
| <ul> <li> One </li> <li> Two </li> </ul> | <ul><li>One</li><li>Two</li></ul> |
About this tool
Minify HTML by removing comments, collapsing whitespace between tags, and trimming unnecessary characters. The result is smaller markup that loads faster. You can also pretty-print compressed HTML back into a readable, indented format.
The tool processes standard HTML and keeps inline scripts and styles intact. Everything runs client-side, so your markup never leaves the browser.
Frequently asked questions
Does the minifier remove HTML comments?
Yes. All HTML comments are removed during minification to save bytes.
Will minifying break my inline JavaScript or CSS?
The minifier focuses on HTML structure and whitespace. Inline script and style blocks are preserved as-is to avoid breaking functionality.
Can I pretty-print minified HTML?
Yes. You can switch to pretty-print mode to add proper indentation and line breaks to compressed HTML, making it easier to read and debug.
