HTML Minifier & Code Optimizer Engine

Your HTML

Result

0 Boriginal
–result
–smaller

Runs in your browser with html-minifier-terser and js-beautify. Your code is not uploaded.

What HTML minification does

The minifier removes comments and collapses runs of spaces and line breaks between tags to a single space. It also drops attributes that browsers assume anyway, such as type="text/javascript" on scripts, shortens the doctype to <!doctype html>, and writes boolean attributes as disabled instead of disabled="disabled". With the option ticked, CSS inside <style> and JavaScript inside <script> are minified as well.

The tool uses conservative whitespace collapsing: one space is kept where there was whitespace, so inline elements like links and bold text keep their spacing and the page looks exactly the same. Content inside <pre> and <textarea> is never changed.

When is it worth it?

For most websites HTML minification saves 5–20% of the page size, and less after gzip compression. It matters most for large static pages, email templates and HTML snippets you paste into widgets or page builders. On WordPress, a caching plugin can minify HTML automatically for every page.

Beautify (format) mode

Beautify indents nested tags so you can read and edit code copied from a page source, an email or a minified template.

Good to know

  • Conditional comments and server-side code (PHP, template tags) are not understood by the minifier. Only minify the final HTML, not template files.
  • If a broken tag is found, the minifier may close it for you. Check the result in a browser before you publish.
  • Keep your original file and minify a copy.

Related: CSS Minifier · JavaScript Minifier · Markdown to HTML