Runs 100% in your browser — nothing is uploaded
Formatters & Minifiers

HTML Minifier / Optimizer

Shrink HTML by stripping comments, collapsing whitespace, and minifying inline CSS/JS — with a live savings summary.

HTML Minifier / Optimizer
Client-side

About this tool

The HTML Minifier reduces the byte size of your HTML by stripping non-essential content: HTML comments, redundant whitespace between tags, and — optionally — closing tags the HTML5 spec allows browsers to infer (like a trailing </li> before the next <li>). Every optimization is a toggle, so you control exactly how aggressive the minification is.

Unlike the HTML Formatter (which reflows HTML for readability), this tool is purpose-built for production: smaller HTML means faster time-to-first-byte, less bandwidth on mobile connections, and lower CDN egress costs. IE conditional comments (<!--[if IE]>...<![endif]-->) are automatically preserved even when "Remove comments" is enabled, since stripping them would change page behavior in legacy browsers still relying on them.

Two additional toggles handle inline assets: "Minify inline <style>" collapses whitespace inside <style> blocks, and "Minify inline <script>" strips comments and extra whitespace from inline <script> tags (not external files, and not a full JS minifier — for that, use the JavaScript Minifier tool, which uses terser for real compression and mangling).

The output panel shows a live "Saved X% · A KB → B KB" summary so you can see the exact impact of each toggle. All processing runs entirely in your browser with a custom, dependency-free minification routine — no third-party library, no network request, no server ever sees your markup.

FAQ

Does minifying HTML break anything?
With default settings (comments removed, whitespace collapsed), no — these are purely cosmetic changes that do not affect rendering. Enabling "Remove optional closing tags" relies on HTML5's tag-inference rules; while browsers handle this correctly, it can make hand-editing the output harder, so it is off by default.
Why are some comments preserved even with "Remove comments" on?
IE conditional comments (<!--[if IE]>...<![endif]-->) control conditional markup for legacy Internet Explorer versions and are functionally part of the page logic, not documentation. This tool always preserves them regardless of the comment-removal toggle.
What are "optional closing tags"?
The HTML5 spec explicitly permits omitting certain closing tags when the parser can unambiguously infer where an element ends — for example, </li> before another <li>, or </p> before a block-level element. This tool can strip a conservative set of these (li, p, td, tr, th, option, dt, dd) when the toggle is enabled.
Does the inline script minifier actually minify JavaScript?
No — it only strips line comments and collapses whitespace inside inline <script> blocks. It is not a real JS parser and does not rename variables or perform dead-code elimination. For genuine JavaScript compression, run the code through the dedicated JavaScript Minifier tool, which uses terser.
How much smaller will my HTML get?
It depends entirely on your source: heavily indented, comment-laden HTML with inline styles and scripts can shrink 20-50%. Already-compact server output may see only a few percent. The live savings pill shows the exact result for your input.