HMin

HTML Minifier

Minify HTML and remove unnecessary bytes

Web Frontend
πŸ”’ 100% client-side β€” your data never leaves this page
Maintained by Evanβ€’Updated: September 30, 2026
Options
Input

Paste HTML first to minify it and inspect size savings immediately; comment and whitespace strategy notes are available in Advanced mode.

Output
Minified HTML will appear here
πŸ”’ Processed locally in your browser
Page reading mode

The full guide also includes pitfalls, worked examples, snippets, FAQs, and related tools for checking results or troubleshooting.

About this tool

Apply optional comment removal and conservative whitespace cleanup to HTML snippets. Quoted attributes and complete pre, textarea, script and style blocks are preserved. Compare raw byte sizes, then verify spacing and template behavior in the destination; this is not a full HTML optimizer.

Production Snippets

Example

text

<span>a</span>  <span>b</span>
β†’ <span>a</span> <span>b</span>

Scenario Recipes

01

Reduce whitespace without merging inline words

Goal: Check a snippet whose separating space affects text.

  1. Enter <span>a</span> <span>b</span>.
  2. Keep Collapse whitespace on and verify one separating space remains.
  3. Disable the option when the destination uses whitespace-preserving CSS.

Result: Quoted attributes and complete raw-text blocks are protected, while ordinary text whitespace is collapsed.

Failure Clinic (Common Pitfalls)

This tool does not remove attribute quotes or infer CSS whitespace rules

Cause: There is no aggressive attribute mode, CSS evaluation or framework template parser.

Fix: Keep comments required by templates and compare the output in the actual page; use a parser-based build tool for complex documents.

Frequently Asked Questions

What does whitespace collapse preserve?

Quoted attributes, complete pre/textarea/script/style blocks and retained comments are kept intact. Outside those regions, ordinary whitespace runs become one space, including a separator between inline tags. The tool does not minify JavaScript or CSS inside protected blocks.

Can whitespace collapse still change rendering?

Yes. This is a lightweight text cleanup, not an HTML/CSS parser. It cannot infer computed white-space styles, framework template rules, malformed markup, or every nested raw-text case. Disable whitespace collapse when spacing is meaningful and test the result in the actual page.

Should I remove every HTML comment?

Only if comments are dispensable. Template directives, conditional email comments and build markers may affect downstream processing. Turn Remove comments off when those must remain. The byte counter measures uncompressed UTF-8 text, not gzip/Brotli transfer size or page speed.

Keep browsing