# Minify HTML source code

> Remove comments and unnecessary whitespace from HTML while keeping the document readable to browsers.

Canonical: https://staticx.site/html-minifier

## Reduce HTML noise

Remove comments and extra whitespace from HTML when a compact file is useful.

## Keep browsers happy

The minifier is conservative and avoids changing the meaning of normal HTML documents.

## Use after review

Minify only after the readable source has been reviewed and validated.

## How to use HTML Minifier

Compact reviewed HTML when smaller output is useful and future editing is already accounted for.

1. **Paste reviewed HTML** — Start from markup that has already been checked for correctness.
2. **Minify output** — StaticX removes unnecessary comments and whitespace.
3. **Preview final page** — Use the minified file in context and verify the page still renders as expected.

## Minification is useful, but it should not hide mistakes.

Small static sites often do not need aggressive minification, but compact output can help when generated pages are large or copied through systems with size limits.

Keep a readable source version somewhere in your workflow. Once minified, future debugging becomes harder.

## Minification tradeoffs

- **Removes comments** — Avoid leaving internal notes or accidental debug comments in public files.
- **Not a build pipeline** — For large projects, use your framework build tool for full optimization.
- **Validate before deploy** — Run a preview after minification to catch unexpected layout changes.

## FAQ

### Will minification improve performance?

Sometimes, but HTML size is only one factor. Images, scripts, CSS, and caching usually matter more.

### Can I edit minified HTML later?

You can, but it is harder. Format it again before editing.

### Does minification remove secrets?

No. Never put secrets in public HTML.

[View on staticx.site](https://staticx.site/html-minifier)
