Safe HTML Minifier

Remove ordinary HTML comments and outer whitespace without rewriting text, scripts, styles or template content.

Tool

Result will appear here...

Example

<!-- remove this comment -->
<div>
    <h1>Title</h1>
</div>

Output:

<div>
    <h1>Title</h1>
</div>

How to use

  1. Paste your HTML code
  2. Click Minify
  3. Copy the result

What is this tool?

This conservative HTML minifier removes ordinary comments and whitespace around the whole document. It intentionally preserves internal whitespace because spaces between inline elements, content in <pre>, scripts, styles and template fragments can be meaningful.

For production builds, use an HTML-aware parser with settings matched to your framework. This tool favors preserving behavior over claiming the smallest possible output.

Related tools

🖥 HTML Preview Editor 📝 HTML to Markdown 📝 Markdown to HTML