Tool Logo

HTML Minifier

Make HTML smaller without changing how the page looks or works.

0 characters

Loading tool…

How to use the html minifier

The minifier uses html-minifier-terser, a widely used HTML minifier. It collapses whitespace conservatively, so a space between inline elements stays and the page renders the same, and it leaves <pre> and <textarea> content untouched. Comments can be removed, and inline CSS and JavaScript are minified too (with clean-css and Terser), so a // comment in a script can't break the code.

  1. Paste your HTML or upload an .html file.
  2. Choose whether to minify inline CSS and JavaScript and remove comments.
  3. Check the size saving and copy the minified HTML.

When to use it

  • Static sites

    Shrink hand-written HTML pages before uploading them.

  • HTML emails

    Reduce email size to stay under clipping limits.

  • Embedded snippets

    Make widgets and templates smaller before embedding them.

Frequently asked questions

Can minifying break my page?

Not with these settings: whitespace is collapsed conservatively, so text between inline elements keeps its space, and <pre> and <textarea> content isn't changed. Inline scripts are minified with a real JavaScript minifier, not by joining lines.

How much smaller will my HTML get?

Typically 10 to 30 percent for hand-written HTML, more if it has many comments or large inline scripts and styles. The saving is shown under the result.

Does it minify inline CSS and JavaScript?

Yes, if you choose to. CSS inside <style> is minified with clean-css and JavaScript inside <script> with Terser.

Are comments removed?

HTML comments are removed by default. Choose "Keep" if you need them, for example conditional comments for old email clients.

Is my HTML uploaded?

No. Everything runs in your browser; nothing you paste or upload is sent to our servers.