Skip to main content

HTML Minifier

Runs locally

Minify HTML markup safely while preserving preformatted blocks and tracking byte savings.

What is HTML Minifier?

Reduce HTML payload size by collapsing whitespace between tags and stripping HTML comments while protecting <pre>, <code>, and <textarea> contents.

How to use HTML Minifier

  1. Step 1

    Paste HTML into the input editor.

  2. Step 2

    Toggle comment removal and whitespace options.

  3. Step 3

    Copy or download the compressed HTML.

Features

  • Preserves whitespace inside <pre>, <code>, and <textarea>
  • Optional HTML comment stripping
  • Byte savings percentage in the status bar
  • Integrated HTML validator diagnostics
  • Switch instantly to Format or HTML to JSX
  • Runs locally in your browser

Example

Input

<!-- header -->
<div class="box">
  <span>Hi</span>
</div>

Output

<div class="box"><span>Hi</span></div>

Removes comments and inter-tag indentation.

Frequently asked questions

Does HTML Minifier preserve conditional comments or <pre> blocks?

Whitespace inside <pre>, <code>, and <textarea> is always preserved.

How much size does minification save?

The status bar shows the exact percentage reduction in bytes.

Are my templates sent to a server?

No, everything runs locally.

Can I beautify the HTML again?

Yes, switch the mode to Format.