DO IT EASY APP
English

HTML minifier

Strip comments and extra whitespace from HTML to shrink its size. Content of pre and script is left alone.

  • No sign-up, no fees.
  • Removes comments and extra whitespace from HTML.
  • Can also minify CSS inside <style>.
  • Leaves <pre>, <textarea> and <script> content alone.
  • Shows how many bytes you saved.
  • What you type is processed, but never shared with anyone.

How to use the HTML minifier

You want your page to load faster or your email template to be lighter. Three steps:

  1. Paste the HTML. Put your page or a snippet into the HTML code box.
  2. Set the options. Turn on or off removing comments, collapsing whitespace and minifying the CSS inside <style>.
  3. Copy. The minified HTML and the size you saved appear below; take it with Copy.

What is HTML minifying?

The indentation, line breaks and comments in an HTML file make code easier to read but aren't needed by the browser. Minifying removes them and brings the file down to fewer bytes. A smaller file downloads faster, which matters on mobile connections and for email templates. The way the page looks and works should not change.

What you need to know

  • Inline spacing is kept: the single space between <b>a</b> <i>b</i> isn't removed, otherwise the words would run together.
  • Block tags are tidied: whitespace next to tags like <div>, <p> and <li> is removed.
  • Left alone: whitespace inside <pre> and <textarea> is meaningful and stays; <script> content also stays as it is.
  • Conditional comments (<!--[if IE]>) are kept.
  • This tool doesn't minify JavaScript; only HTML and CSS inside <style>.

Tips

  • Before you publish the minified file, open the page once in a browser and check nothing broke.
  • For special characters in HTML, use the HTML entity encoder.
  • To produce HTML from Markdown, there's the Markdown preview tool.

Frequently asked questions

Is HTML minifying free?

Yes, it's free with no sign-up.

Could my page break?

The tool is careful: it keeps meaningful spaces and the content of pre and script. Still, we recommend trying the result before you publish it.

Does it minify JavaScript too?

No. It only minifies HTML and CSS inside <style>.

Is my code sent anywhere?

What you type is processed, but never shared with anyone. It all happens in your browser.

How much smaller does it get?

It depends on how the code is written. Heavily indented, comment-rich files can shrink by 10-30 percent.

Can I use it for email templates?

Yes, but email clients sometimes need certain comments (like Outlook conditional comments); those are kept.

Related tools