HTML Minifier
Minify HTML by removing comments and whitespace, with inline CSS and JavaScript minified too.
About the HTML Minifier
HTML minification removes the characters browsers do not need – comments, indentation, line breaks and repeated spaces – so pages download a little faster and use less bandwidth. It is most useful for static pages and templates that are served without a build step.
This minifier collapses whitespace safely: it keeps a space where it matters between inline elements, leaves the contents of <pre> and <textarea> and conditional comments untouched, and can also minify inline <style> blocks, style attributes, inline JavaScript (with Terser) and JSON-LD structured data. Turn on gzip or Brotli compression on your server as well – it saves even more than minification.
Frequently asked questions
Can minifying HTML break my page?
Rarely. Spaces between inline elements are kept, and pre, textarea and script contents are handled separately. Always test the minified page before replacing the original.
How much does HTML minification save?
Typically 5–20% of the HTML size before compression. With gzip or Brotli on the server the difference is smaller, but it still helps on large pages.
Should I minify HTML in WordPress?
Use a caching or optimisation plugin that minifies automatically, rather than editing the HTML by hand.