Developer Tools

HTML Minifier

Minify HTML snippets by removing comments, collapsing whitespace, and compacting markup while preserving sensitive blocks such as script, style, textarea, and pre.

View all Developer Tools

Add HTML to see size savings.

Continue Workflow

Related tools to try next

All tools
Browser Local No sign-up

Example

Compact a small card component

Whitespace between tags can be removed while text content remains readable.

Input


                        <article class="card">\n  <h2>Hello</h2>\n  <p>Example content.</p>\n</article>
                      

Output


                        <article class="card"><h2>Hello</h2><p>Example content.</p></article>
                      

Keep preformatted content intact

The minifier preserves pre, textarea, script, and style blocks because whitespace inside those elements can be meaningful.

Input


                        <pre>Line 1\n    Line 2</pre>\n<div> Done </div>
                      

Output


                        <pre>Line 1\n    Line 2</pre><div> Done </div>
                      

Remove review comments before sharing

Removing comments is useful before handing snippets to clients, support teams, or external systems.

Input


                        <!-- TODO: replace copy -->\n<section>\n  <p>Published text</p>\n</section>
                      

Output


                        <section><p>Published text</p></section>
                      

Practical Notes

How to Use

  1. 1. Paste an HTML snippet or full HTML document into the input area.
  2. 2. Choose whether to remove comments, collapse whitespace, and remove spaces between tags.
  3. 3. Click Minify HTML to generate compact markup.
  4. 4. Review the result and copy it when ready.

Features

Use Cases

Frequently Asked Questions

What does the HTML Minifier remove?
It can remove comments, collapse repeated whitespace, trim the document, and remove spaces between tags. It preserves script, style, textarea, and pre blocks to avoid changing code or preformatted content.
Can minifying HTML change how a page looks?
It can in whitespace-sensitive layouts or templates. Review the output and test the rendered page, especially for inline text, email HTML, and framework templates.
Does this tool upload my HTML?
No. HTML minification runs locally in your browser, so pasted markup is not sent to a server.
Should I use this instead of a build tool minifier?
Use this for quick snippets and manual debugging. For production websites, a build pipeline can provide more complete optimization, source handling, and repeatability.
Can I minify email HTML?
Yes, but test the final email carefully. Some email clients are sensitive to table markup, conditional comments, and spacing around inline text.
Why are script and style blocks preserved?
Whitespace and comments inside JavaScript, CSS, textarea, and preformatted blocks may be meaningful. The tool protects those blocks while compacting surrounding markup.