Small Tools
Frontend utility

HTML Minifier

Remove HTML comments and collapse unnecessary whitespace.

● This tool runs entirely in your browser. Your input is never uploaded to our servers.
Output
Your result will appear here…

How to use HTML Minifier

  1. Paste your HTML.
  2. Select Minify.
  3. Compare the result in a browser before you use it.

Example

Input / settings:

<main>
  <!-- greeting -->
  <h1> Hello </h1>
</main>

Output:

<main><h1> Hello </h1></main>

The comment and the whitespace between tags are removed. Spaces at the edges of text become one space.

When to use

Overview

HTML Minifier removes ordinary comments, collapses each run of whitespace in text to a single space, and drops whitespace-only text between tags. Tags and attributes are left exactly as written, and plain text inside script, style, pre and textarea elements is kept. It is a text tool, not a full HTML parser, and it does not shorten attributes or remove optional tags.

Supported input

HTML text

Output details

compact HTML

Common mistakes

Practical tips

Privacy and security

This tool runs entirely in your browser. Your input is never uploaded to our servers. Minification runs locally and only removes comments and whitespace. It does not sanitize markup, so the output does whatever the input did. Removing comments can delete notes you wanted to keep, so check them first.

References

Frequently asked questions

Does HTML Minifier remove optional tags or shorten attributes?

No. Tags and attributes are written back as they were. Only comments and whitespace change.

Which comments does the minifier keep?

Comments that begin with <!--! are kept. All other comments are removed, including conditional comments.

Why did two words run together after minifying?

A space that sat alone between two tags was removed. Put the space inside one of the elements, or use &nbsp;.

Related tools