TTKTheTextKit

HTML Minifier

Paste your HTML and the minified version appears beside it, with the original size, the new size and the percentage saved. You can choose whether to remove comments, collapse whitespace and strip quotes from simple attribute values. Conditional comments for old Internet Explorer are kept, and the text inside pre, textarea, script and style tags is never reflowed. Everything runs in your browser and your code is not uploaded.

Original
432 bytes
Minified
279 bytes
Saved
153 bytes (35.4%)

Removed 2 comments.

Minifying HTML removes characters the browser does not need, so the file is smaller to download. The savings are usually modest because servers already compress text with gzip or Brotli, so treat minifying as a small extra. This tool uses a simple tokenizer, not a full HTML parser: it does not minify the CSS or JavaScript inside style and script tags, and it does not fix invalid markup. Check the result in a browser before you ship it, especially for pages that depend on spaces between inline elements. Everything runs in your browser and your code is not sent anywhere.

Related Tools

[5 suggestions]

About the HTML Minifier

Minifying HTML removes characters that the browser does not need to build the page. The tool removes comments, collapses runs of spaces and line breaks into a single space, drops the spaces between block-level tags such as div, p and li, tidies the spacing inside tags and, if you choose, removes the quotes around values such as class=btn. It keeps one space between inline elements, because browsers show that space, so a b and an i side by side still have a gap. The sample page is 432 bytes before and 279 after, a saving of 35.4%. Real savings depend on how much indentation and how many comments the source has. Servers usually compress text with gzip or Brotli as well, which already removes much of the same repetition, so minifying is a small extra on top. This is a simple tokenizer and not a full HTML parser: it does not minify the CSS or JavaScript inside style and script tags, and it does not repair invalid markup. Always check the result in a browser.

What does an HTML minifier do?▾

It removes comments, extra whitespace and other characters the browser does not need, so the file is smaller to download without changing how the page looks.

Is minified HTML safe?▾

Usually, but whitespace can matter. This tool keeps a single space between inline elements and never touches pre, textarea, script and style content. Test the result in a browser.

Does it minify CSS and JavaScript?▾

It only trims the whitespace around the content of style and script tags. Use a CSS minifier or a JavaScript minifier for the code itself.

Is it worth minifying if my server uses gzip?▾

The gain is smaller, because compression already removes repeated whitespace, but minified HTML is still a little smaller and cheap to produce.

Is my code uploaded?▾

No. The minifying runs in your browser and your HTML is not sent anywhere.