HTML Minifier
Strip comments and collapse whitespace to shrink an HTML file, safely.
Your result will appear here as soon as you add some input.
How to use it
- 1Paste your input into the input box, or type it directly.
- 2Adjust the options if you need something other than the defaults.
- 3The result updates as you type.
- 4Copy the result to your clipboard or download it as a file.
About the HTML Minifier
Whitespace is only collapsed where it is insignificant. The contents of pre, textarea, script and style are lifted out first and put back untouched, which is what stops a minifier from breaking a code sample or a template literal.
Conditional comments are kept, because they are instructions to the browser rather than notes to the reader. Attribute quotes are never dropped - it saves a few bytes and is a classic way to produce subtly broken markup.
Questions people ask
Is your code uploaded to a server?
No. This tool runs entirely in your browser using standard web APIs, so your code never leaves your device. You can confirm it by opening your browser's network panel while the tool runs, or by disconnecting from the internet after the page has loaded.
Is it free, and do I need an account?
Yes, it is free, and there is no account, no sign-up and no watermark on the result. The project is funded by optional donations.