EN
My tools

HTML Minifier

Minify HTML: drop comments, collapse whitespace, shorten boolean and redundant attributes, and compress inline CSS and JSON, keeping pre and textarea intact.

Conditional comments (<!--[if IE]>) are always kept.
Minified HTML
Original size
512 bytes
Minified size
309 bytes
Saved
39.6%

Whitespace inside <pre> and <textarea> is kept. Inline scripts are only trimmed, never rewritten — use a JavaScript minifier for that.

My tools →
Advertisement

Minifying HTML strips what browsers ignore — comments, indentation, line breaks between block elements and redundant attribute values — so pages download and parse a little faster. This minifier tokenizes the markup instead of using blind search-and-replace, so whitespace inside <pre> and <textarea> is left alone, single spaces between inline words survive, and quoted attribute values are never broken.

How to use this tool

  1. Paste the HTML page or fragment.
  2. Choose what to remove: comments, extra whitespace, redundant attributes, attribute quotes.
  3. Leave inline CSS and JSON compression on unless you need the original formatting.
  4. Copy the minified HTML and check the bytes saved.

Formula

saved % = (original bytes − minified bytes) ÷ original bytes × 100

Sizes are UTF-8 bytes. Runs of whitespace become one space; a space next to a block-level tag (div, p, li, td and so on) and whitespace between the elements inside head are removed because they never render. Spaces beside inline boxes such as select, svg or video, and around scripts and kept comments, stay. type="text/javascript" and type="text/css" are dropped because they are the defaults, and boolean attributes like checked="checked" become checked.

Example

A 25-byte snippet <p> + newline + a b + newline + </p> + newline minifies to <p>a b</p>, which is 10 bytes: the whitespace next to the block tags goes and the run between the two words collapses to one space, saving 60%.

Frequently asked questions

Can minifying break my page?

Rarely. The risky cases are CSS that relies on whitespace between inline-block elements and scripts that read comments; both are uncommon. Keep a copy of the original and test the minified page.

Does it minify JavaScript?

No — inline scripts are only trimmed at the start and end, which is always safe. JSON and JSON-LD blocks lose whitespace outside strings. For real JavaScript compression use a JavaScript minifier.

Are conditional comments kept?

Yes. <!--[if IE]> … <![endif]--> blocks are kept even when comment removal is on, and you can keep comments that start with <!--! as well.

How much will I save?

Typically 10–25% on hand-written pages. Gzip or Brotli compression on the server saves more, and the two add up.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). HTML Minifier. https://kakao.mobile/tools/html-minifier/

MLA

“HTML Minifier.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/html-minifier/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement