HTML Minifier

Minify HTML — remove comments and extra whitespace while keeping <pre>, scripts and inline text safe.

Runs in your browser — your data never leaves your device.

About the HTML Minifier

Reduce the size of HTML pages and email templates by removing comments and unnecessary whitespace. Content inside <pre>, <textarea> and <script> is left exactly as it is, and CSS inside <style> can be minified too.

By default the space between inline elements is kept, so <b>Hello</b> <i>world</i> still reads “Hello world”. The aggressive option removes all spaces between tags.

How to use the HTML Minifier

  1. Paste your HTML.
  2. Choose the options.
  3. Copy the minified code or download it.

How it works

Protected blocks are set aside, comments are removed (conditional comments are kept), whitespace is collapsed to single spaces, and spaces next to block-level tags such as div, p, li and table are removed.

Examples

  • <div>\n <p>Hello world</p>\n</div> → <div><p>Hello world</p></div>

Frequently asked questions

Is my text sent to your server?

No. Everything runs in your browser, on your own device. Nothing you type or paste is uploaded or stored.

Does it minify JavaScript?

No. Script content is left unchanged to avoid breaking it. Use a dedicated JavaScript build tool for that.

Category: Developer Tools · Free to use · Last updated Oct 8, 2026