HTML Minifier

What is this?

Drag and drop HTML files into the box above to have them minified by html-minifier.

It runs html-minifier with the following options enabled:

  • remove-comments
  • remove-comments-from-cdata
  • collapse-whitespace
  • collapse-boolean-attributes
  • remove-attribute-quotes
  • remove-redundant-attributes
  • use-short-doctype
  • remove-empty-attributes
  • remove-optional-tags
  • remove-empty-elements
  • minify-js
  • minify-css

Should I Minify My HTML?

You’re already likely minifying your Javascript and CSS to decrease loading time for visitors to your websites. Minifying HTML seems like the next logical step, but it’s not a clear-cut win like minifying CSS and Javascript.

CSS and Javascript are almost always precomputed static assets, so they can easily be minified once and then served to all clients. HTML however is often dynamically generated, and if it is, you’d have to minify it on every request so the savings would have to be larger than the overhead of on-the-fly minification. If you’re serving gzipped content, the savings that come from HTML minification are unlikely to be significant.

HTML minification can be very worthwhile if you’re serving content to clients that don’t support gzip. If you’re serving static html assets, then there’s nothing to lose from minifying them as part of your build process, even if the savings is small.

The author of the html-minifier that powers this tool has a great breakdown of how the tool works and some examples of the potential savings on his blog. Definitely check out the costs and benefits section if you’re still unsure if minifying HTML makes sense for your use case: http://perfectionkills.com/experimenting-with-html-minifier