# HTML Minifier

> Shrink HTML by stripping comments and collapsing whitespace. See byte savings in real time.

URL: https://uttir.com/html-minifier
Categories: developer-tools, web-tools
Privacy: All processing is local. Your HTML never leaves the browser.

## About

Minifying HTML removes the comments, indentation, and excess whitespace that make source readable but inflate file size. For production builds, a few percent off every page adds up to faster loads and lower bandwidth costs.

Paste your HTML on the left, get the minified version on the right, and see the byte savings in real time. Toggle the "remove optional tags" option for an extra pass that drops redundant </li>, </p>, and similar closures that the browser will infer anyway.

## How to use

1. **Paste your HTML** — Drop a snippet, a partial, or a full document.
2. **Pick options** — Toggle "remove optional tags" if you want an extra squeeze.
3. **Copy the minified HTML** — Use the Copy button to grab the result.

## Examples

### Comment stripping

HTML comments are removed entirely.

Output:

```
<!-- hidden --><p>hi</p> → <p>hi</p>
```

### Whitespace collapse

Multiple spaces and newlines between tags become a single space.

Output:

```
<p>hello   world</p> → <p>hello world</p>
```

## FAQ

### Will minifying break my HTML?

For most static markup, no. The minifier does not touch the contents of <script> or <style> tags. If your code relies on subtle whitespace inside <pre> elements, use the option to keep certain blocks intact.

### How much smaller does it get?

Hand-written HTML with comments and indentation typically shrinks 10-30%. Generated HTML with minimal whitespace may only shrink a few percent. The byte counter on this page shows the actual savings for your input.

### Will minification break my HTML?

No — the minifier only removes whitespace, comments, and optional tags. The browser parses the minified HTML identically. Always test the minified output, but for well-formed HTML, it is safe.

## Related tools

- [CSS Minifier](https://uttir.com/css-minifier) — Shrink CSS by stripping comments, collapsing whitespace, and tightening punctuation. See byte savings live.
- [JavaScript Minifier](https://uttir.com/js-minifier) — Quick JS minifier that strips comments and collapses whitespace. Best for trusted, simple code snippets.
- [Markdown to HTML Converter](https://uttir.com/markdown-to-html) — Convert Markdown to clean HTML. Headings, lists, links, images, code blocks, blockquotes, and inline formatting.

---

For the full HTML page with the live tool, visit https://uttir.com/html-minifier.
This file is the markdown rendering at https://uttir.com/html-minifier.md. See https://uttir.com/llms.txt for a site-wide summary.
