Skip to content

Minify HTML

Remove unnecessary comments, whitespace and line breaks from HTML to reduce its size before publishing it.

Processed on your device. Nothing is sent to any server.

Removes HTML comments and reduces any run of spaces, tabs or line breaks to a single space.

Use cases

  • Reducing an HTML template's size before publishing it.
  • Optimizing a static page's load time.
  • Preparing compact HTML to embed in another system.

How it works

  1. 1

    Paste your HTML

    Type or paste the formatted HTML code.

  2. 2

    Minify it

    Click Minify and copy or download the compact result.

Technical details

  • The contents of <pre>, <textarea>, <script> and <style> are left untouched: collapsing them would change preformatted text or break a script's // comment.
  • One space is kept between tags, because removing it would join words from inline elements ("<b>hello</b> <i>world</i>").
  • It doesn't rewrite attributes, drop quotes or minify inline CSS or JavaScript. For those, use the CSS minifier or a build tool.
  • Legacy conditional comments (<!--[if IE]>) are removed too.

Frequently asked questions

Can it change how my page looks?

It shouldn't: it only removes comments and repeated whitespace, and leaves blocks where whitespace matters untouched. Still, check the result before publishing, especially if your CSS relies on whitespace (white-space: pre).

← Web & SEO