# HTML Minifier

> Shrink HTML by removing comments and collapsing whitespace between tags, with options for conditional comments. Script, style, and pre bodies are protected; runs in your browser.

[bfotkit](/) Runs in your browserCategories ▾[All tools 307](/en/tools/)[Text tools9](/en/tools/text-tools/)[Image tools27](/en/tools/image-tools/)[PDF tools20](/en/tools/pdf-tools/)[Social media tools97](/en/tools/social-media-tools/)[Security tools8](/en/tools/security-tools/)[Coding tools25](/en/tools/coding-tools/)[CSS tools12](/en/tools/css-tools/)[Color tools6](/en/tools/color-tools/)[Miscellaneous tools103](/en/tools/miscellaneous-tools/)

[All tools ↗](/en/tools/)[EN](/en/tools/html-minifier/)[PT](/pt-br/ferramentas/minificador-html/)[DE](/de/werkzeuge/html-minimierer/)[ID](/id/alat/peminim-html/)[RU](/ru/instrumenty/minifikator-html/)

CODING & JSON · BFOTKIT

# HTML Minifier | BFOTKit

Remove comments and collapse whitespace between tags to cut HTML size, with options to keep conditional comments and control how aggressively whitespace is squeezed.

InputIndent2 spaces4 spacesTab remove comments keep conditional comments collapse whitespace between tags

Load sampleMinify

OutputCopyDownloadClear

All processing happens in this browser tab. Nothing is sent to a server.

GUIDE

## How to minify HTML

### What gets removed

The minifier strips comments (optionally keeping old conditional comments), removes line breaks and indentation between tags, and collapses runs of whitespace into single spaces. Bytes saved matter most on templates served on every page load.

### Whitespace between inline elements

Collapsing the whitespace between tags removes the spaces that render between inline elements such as emphasized words or inline images. If your layout depends on those visible spaces, turn the collapse option off or add your own explicit spacing in CSS.

### Script and style bodies are preserved

Contents of script, style, and pre elements are not touched: collapsing whitespace inside them would break code and preformatted text. Minify those blocks with their own dedicated tools instead.

### Verify after minifying

Minify, download, and open the result in a browser next to the original. If a page depends on whitespace-sensitive inline spacing, compare carefully. Keep the readable original as your working copy and minify at build or deploy time.

HELP / FAQ

## HTML minifier questions

### How much smaller will my HTML get?

Typical hand-written templates shrink by 10 to 30 percent, mostly from indentation and comments. Machine-generated markup with long attribute lists saves less; heavily commented templates save more.

### Does it remove conditional comments?

Only if you allow it. The keep-conditional option preserves comments like if-lte IE 9 that some legacy pages still rely on, and strips all others.

### Is it safe for inline SVG?

Yes. SVG elements are tags like any other; the minifier only removes whitespace between tags, never attribute values, so path data inside attributes stays intact.

### Can I minify every build automatically?

This tool is manual and private, good for one-off files. For pipelines, run minification at build time with your own tooling; the rules used here are deliberately conservative for the same reasons.

EXPLORE BY CATEGORY · BFOTKIT

## More tools like this

Pick a category to see every tool in it — then open one and discover related tools.

[All tools 307](/en/tools/)[Text tools 9](/en/tools/text-tools/)[Image tools 27](/en/tools/image-tools/)[PDF tools 20](/en/tools/pdf-tools/)[Social media tools 97](/en/tools/social-media-tools/)[Security tools 8](/en/tools/security-tools/)[Coding tools 25](/en/tools/coding-tools/)[CSS tools 12](/en/tools/css-tools/)[Color tools 6](/en/tools/color-tools/)[Miscellaneous tools 103](/en/tools/miscellaneous-tools/)

[Coding toolsPrivate JSON formatter and text cleanup tools↗](/en/tools/private-json-text-cleanup/)[Coding toolsURL Slug Generator↗](/en/tools/url-slug-generator/)[Coding toolsBase64 Encoder/Decoder↗](/en/tools/base64-encoder-decoder/)[Coding toolsURL Encoder/Decoder↗](/en/tools/url-encoder-decoder/)[Coding toolsHTML Encoder/Decoder↗](/en/tools/html-encoder-decoder/)[Coding toolsHAR Sanitizer↗](/en/tools/har-sanitizer/)[Coding toolsJSON Formatter↗](/en/tools/json-formatter/)[Coding toolsJSON Validator↗](/en/tools/json-validator/)

[Browse all tools →](/en/tools/)

[bfotkit](/)[All tools](/en/tools/)[Privacy Policy](/en/privacy-policy/)[Terms & Conditions](/en/terms-and-conditions/)[About Us](/en/about-us/)[Contact Us](/en/contact-us/)

Useful tools. No fuss. © 2026 BFOTKit[bfotkit.com ↗](https://bfotkit.com/)
