Boneyard Tools

HTML Minifier

Paste HTML to compress it instantly. The minifier removes comments and collapses needless whitespace while leaving pre, textarea, script and style content untouched, then shows how many bytes you saved.

How to minify HTML

  1. Paste or type your HTML into the input box.
  2. Read the minified markup and the size saved in the badge above the output.
  3. Copy the result or download it as an .html file.

Examples

Strip comments and whitespace

<!-- nav -->
<div class="box">
  <p>Hello   world</p>
</div>
<div class="box"><p>Hello world</p></div>

Frequently asked questions

Is my HTML sent to a server?

No. Minification runs entirely in your browser, so your markup never leaves your device.

How does HTML minification reduce file size?

It deletes comments and collapses repeated spaces, tabs and line breaks, including the whitespace between tags, so the same page ships in fewer bytes.

Will it break my inline scripts, styles or preformatted text?

No. Content inside pre, textarea, script and style tags is preserved exactly, so code, CSS and whitespace-sensitive blocks stay intact.

Are IE conditional comments kept?

Yes. Conditional comments such as the if lt IE 9 block are functional, so they are detected and left in place while ordinary comments are removed.

Does minifying HTML change how the page looks?

It should not. Only insignificant whitespace and comments are removed, so the rendered output stays the same in the browser.

Related tools