HTML Minifier

Reduce HTML comments and tag formatting conservatively while preserving meaningful text spacing.

✓ Free to use · Runs in your browser · No sign-up

Make your code smaller

Paste source code, then select Minify. The output is text only: your code is never run.

Conservative mode removes ordinary comments and extra spacing inside start tags. Text spacing, quoted attributes, preformatted text, styles and scripts are preserved. Some files may not become smaller.

Your data is processed locally in your browser and is not uploaded to our servers.

Up to 100,000 characters. Paste text, not a file URL.

How to use HTML Minifier

  1. Paste an HTML fragment or document.
  2. Select Minify to remove ordinary comments and redundant spacing inside opening tags.
  3. Compare byte counts and review the output before copying or downloading the .html file.

A closer look

HTML whitespace can be visible or meaningful, especially between inline elements and inside pre, textarea, script, style, or CSS white-space layouts. This tool deliberately preserves all text-node whitespace and quoted attribute values. A real HTML parser identifies comments and tag source locations, and edits are applied to those original ranges rather than rebuilding the document. Ordinary comments are removed while common conditional, license, and template-marker comments are retained. Malformed syntax reported by the parser is shown as an error.

A practical example

Compact a small HTML fragment containing an ordinary comment and extra tag spacing. Spaces inside text are preserved so words do not accidentally join together.

A useful tip

Conservative minification may save little or nothing in an already compact file. This tool does not minify embedded CSS or JavaScript, remove attributes, sanitize HTML for publication, or guarantee behavior for applications that read comments as data.

Good questions. Simple answers.

Will the HTML run while I minify it?

No. Input and output remain text. The parser does not create an active browser page or load referenced resources.

Why are spaces between tags still present?

Removing them can join words or change layouts. Preserving page meaning is preferred over a smaller but potentially different output.

Explore all developer tools for related tasks and category-specific guidance, or read how Toolzafi handles your data.

A few more useful tools