HTML Minifier

Paste HTML to get a smaller version. Runs of spaces and line breaks in text become one space and comments are removed. Code blocks and scripts are left alone.

Use the tool

Loading the tool…

About HTML Minifier

Paste HTML and get back a smaller version with comments and extra white space removed. Conditional comments are kept. Removing white space between tags can close up inline elements, so check the layout after you minify.

Worked example

Paste a page with comments and indentation. The tool shows how much smaller the output is.

Limits

Minifying can change how inline text sits on the page. Keep your original file for editing, and test the minified version in a browser.

How to use HTML Minifier

  1. Paste your HTML.
  2. Choose whether to remove comments and whether to remove white space between tags.
  3. Copy the minified HTML and test it in a browser.

Good to know

  • Content inside pre, textarea, script and style is never changed.
  • Removing all white space between tags makes the page smaller but can close up inline items, such as two links with a space between them.
  • Attribute values and tag names are not changed. White space between attributes becomes a single space.
  • The tool does not fix broken HTML, and it does not shorten attribute names or remove optional tags.

Frequently asked questions

Is it safe for every page?

The default settings keep a space wherever one existed, which is the safest choice. Test the result in a browser before using it.

Are conditional comments kept?

Yes. Comments such as <!--[if IE]> are kept even when comments are removed.

Is anything I type saved or sent?

No. The work happens in your browser on this page, and nothing is stored or sent to us.