Skip to content
Swizztool

HTML Minifier

Client-side HTML minifier and compression utility. Reduces file sizes and page load times by removing HTML comments, redundant whitespace, and formatting overhead.

Content inside <pre>, <textarea>, <script>, and <style> is left exactly as written.

Your text 533 chars · 22 lines

Result 533 B → 417 B (22% smaller)

How to use HTML Minifier

  1. Paste your HTML.
  2. Choose whether to remove comments and collapse whitespace.
  3. The minified HTML and the size saving update as you type.
  4. Copy or download the result.

About HTML Minifier

Shrink HTML by removing comments and collapsing whitespace, and see how many bytes you saved. Content inside <pre>, <textarea>, <script>, and <style> is left exactly as written, so code and preformatted text are never broken.

Related tools: JSON Formatter & Validator, Base64 Encoder / Decoder, URL Encoder / Decoder, JWT Decoder

What gets removed

Comments are removed except Internet Explorer conditional comments, which some email templates still rely on. Whitespace and line breaks between tags are collapsed, while a single space between inline elements, such as two links on one line, is kept so words do not run together.

The minifier does not rename attributes, remove optional tags, or rewrite your markup. It is a safe, predictable clean-up rather than an aggressive optimizer.

When minifying helps

Most web servers compress HTML with gzip or Brotli already, so minifying usually saves less over the network than the size counter suggests. It matters most for HTML embedded in email, stored in databases, or inlined in JavaScript.

Common uses

Email templates
Reduce the size of HTML emails to stay under clipping limits.
Embedded snippets
Compact HTML stored in a CMS field or JSON string.
Static pages
Minify hand-written pages before uploading them.
Removing notes
Strip developer comments before sharing markup publicly.

Questions about HTML Minifier

Will minification break inline scripts or styles?
No, standard minification preserves script contents and tag structures while removing redundant whitespace.
Why is the saving small?
Well-formatted HTML has little extra whitespace. Comments and deep indentation give the biggest savings.
Is my HTML uploaded?
No. Minifying happens in your browser.
Are IE conditional comments kept?
Yes. Comments that start with [if are kept because some email templates rely on them.
Does it minify inline CSS and JavaScript too?
No. Content inside <style> and <script> is left exactly as written. Use the CSS Minifier for styles.

Comments

Questions, ideas, or a bug in HTML Minifier? Let us know.