How to use the HTML Minifier
- Paste HTML in the left box or open an .html file.
- The minified HTML appears on the right, with the size saved underneath.
- Turn options on or off: remove comments, collapse whitespace, remove whitespace between tags, and minify inline CSS.
- Copy or download the result.
What gets removed
- Comments like
<!-- nav -->. Internet Explorer conditional comments are kept. - Runs of whitespace: line breaks, tabs and indentation are collapsed to a single space.
- Whitespace between tags (optional): makes the file smallest, but can remove the small gap between inline elements like buttons or links placed side by side, so check the page afterwards.
- Inline CSS in
<style>tags is minified with CSSO.
JavaScript inside <script> tags is kept as it is, to avoid breaking it. Minify it separately with a build tool, and minify stylesheets with the CSS minifier.
Is it worth it?
Minifying usually saves 10–25% of an HTML file. If your server already compresses pages with gzip or Brotli, the difference after compression is smaller, but every byte still counts on slow mobile connections.
Frequently asked questions
Is my HTML uploaded?
No. It's formatted in your browser and never leaves your device.
Does it handle CSS and JavaScript inside the page?
Yes. Code inside <style> and <script> tags is formatted or minified along with the HTML.
Can I undo minifying?
Yes, mostly: paste the minified HTML into the HTML Formatter to indent it again. Removed comments can't be brought back.
Why did a space disappear between my buttons?
Remove whitespace between tags also removes the space browsers draw between inline elements. Turn that option off.
Updated