Skip to content
QuickTool logoQuickTool

HTML Minifier

Minify HTML by removing comments and spaces

Start

<div> Hello world </div>

Description

The HTML Minifier compresses markup by removing comments, collapsing whitespace, and trimming gaps between tags. Use it to shrink payloads for quick tests or to inspect how much space comments and line breaks consume.

This lightweight minifier runs entirely in your browser and is suitable for small snippets and prototypes. For production bundling, pair it with build‑time tools.

Key features

  • Remove <!-- comments -->
  • Collapse multiple spaces and newlines
  • Strip gaps between tags (> <><)
  • Options to keep comments and preserve spaces

Common use cases

  • Sharing compact code samples
  • Testing HTML payload sizes
  • Cleaning markup before embedding

Privacy & security: minification happens locally in your browser; no uploads.

How to Use

  1. Paste HTML in the left panel.
  2. Toggle options like “Remove comments” and “Collapse whitespace”.
  3. Review the minified output on the right.
  4. Click “Copy Output” to copy the minified HTML.
  5. Use “Sample” to load an example snippet.
  6. Click “Clear” to reset.

Tips

  • Keep comments when they contain licenses or metadata you need.
  • Whitespace can be significant in preformatted blocks—verify rendering.
  • Pair with the CSS/JS minifiers for inline assets.

Troubleshooting

  • Output breaks layout → Disable aggressive whitespace collapse.
  • Lost important comments → Turn off “Remove comments”.
  • Nothing changes → Input may already be compact; add line breaks to test.

Example

Example 1: Comments and spaces

Input:

<div>  Hello <!-- comment --> world </div>

Output:

<div>Hello world</div>

Comments removed and spaces collapsed.

Example 2: Tag gaps

Input:

<span> A </span> <span> B </span>

Output:

<span> A </span><span> B </span>

Inter‑tag spaces removed (>< preserved).

FAQ

Is this safe and local?

Yes. Everything runs in your browser.

Why did formatting disappear?

Minification collapses whitespace; disable it for preformatted content.

Can I keep specific comments?

Enable “Keep comments”; for fine control, retain comments before pasting.

Does it minify inline JS/CSS?

Only basic whitespace reductions. Use dedicated minifiers for thorough compression.

Production usage?

Use build tools; this is best for quick tests and snippets.