Developer Tools

HTML Minifier

Strip the bytes browsers do not need from your HTML. Comments and redundant whitespace are removed, inline styles and scripts are compressed, and you see how much was saved.

  • Runs in your browser
  • No sign-up
  • Free to use

How to use HTML Minifier

  1. Paste your HTML or open an .html file.
  2. Tick the optimisations you want. The defaults are safe for almost every page.
  3. Select Minify HTML.
  4. Check the size reduction, then copy or download the minified markup.

HTML Minifier features

Whitespace collapsing

Runs of spaces and line breaks are reduced without changing how inline text is spaced.

Comment removal

HTML comments are stripped, while conditional comments are kept.

Inline CSS and JS minified

Code inside style and script elements is compressed as well.

Optional aggressive modes

Remove optional attribute quotes and redundant attributes for extra savings.

Size report

Shows the before and after size and the percentage saved.

Local processing

Templates and markup are not uploaded.

When to use HTML Minifier

  • Reducing the size of a static landing page before deploying it.
  • Shrinking HTML email templates to stay under clipping limits.
  • Compressing an HTML snippet embedded in JavaScript or JSON.
  • Squeezing a single-file demo or widget.

HTML Minifier FAQ

How much does minifying HTML save?

Typically 10–25% of the HTML file, more if it contains many comments or large inline scripts and styles. With gzip or Brotli enabled on the server, the additional saving is smaller but still worthwhile.

Can minification break my page?

The default options are conservative. Problems arise mainly where whitespace is meaningful, such as inline-block layouts that rely on gaps between elements, or pre-formatted text, which the minifier leaves alone. Test the output if you enable the aggressive options.

Is it safe to remove attribute quotes?

HTML allows unquoted attribute values when they contain no spaces or special characters, and the minifier only removes quotes in those cases. Some templating systems and XML-based tools expect quotes, so the option is off by default.

Does it handle template tags?

Server-side template syntax may be altered or cause errors. Minify the rendered HTML rather than the template source.

Should I minify HTML by hand?

For a production site, build minification into your deployment process. This tool suits one-off files, emails and quick checks.

Is it safe to remove optional tags and attribute quotes?

Yes, when done according to the HTML specification, browsers build exactly the same page. Problems only arise with tools that read HTML as XML, such as some feed parsers and older email clients. For those, keep the conservative options, which remove only comments and whitespace.

Can minifying HTML break a page?

Rarely, but it can. Whitespace between inline elements such as links or buttons is visible as a small gap, and removing it changes the layout slightly. Text inside pre and textarea elements must keep its spacing, and inline scripts that rely on line breaks need care. Compare the page before and after, and keep the original file as your source.

What HTML minification removes

HTML written for people contains a lot that browsers ignore: indentation, line breaks between tags, comments explaining the markup. Minification deletes those. It can also apply rules from the HTML specification that permit shorter forms, such as dropping quotes around simple attribute values or omitting attributes whose value is the default.

The gain per file is modest compared with images, but HTML is on the critical path: the browser cannot start fetching anything else until it has received the document. Fewer bytes mean the first packets carry more of the page, which helps the earliest moments of loading, particularly on slow mobile connections.

Minification works best combined with compression on the server. Gzip or Brotli compression of text files typically reduces them by 70 to 80 per cent, and minifying first removes redundant characters that would otherwise still need to be encoded. Some markup must be handled carefully: whitespace inside pre and textarea elements is meaningful, inline scripts and styles have their own syntax, and conditional comments or template placeholders may need to be preserved. Always test the minified page before deploying it.

A sensible routine is to minify as the last step of publishing and never by hand. Keep the readable HTML in your project, let a build step or this tool produce the compact copy, and upload only that copy. If something looks different afterwards, compare the two versions line by line and switch off the option that caused it.

Other useful tools