HTML Minifier

Shrink HTML pages by collapsing whitespace and removing comments, while keeping the content of pre, textarea, script and style intact — free and instant. Your markup is processed in your browser and never uploaded.

How to use the HTML Minifier

  1. Paste your HTML. Drop a full page, an email template or a fragment of markup into the box above.
  2. Pick your options. Choose whether to remove comments and whether to collapse whitespace, then press Minify HTML.
  3. Copy or download. Copy the compact markup to your clipboard or download it as an .html file. The size panel shows exactly what you saved.

About this tool

This free online HTML minifier compresses markup so pages transfer faster and cache better. It collapses runs of spaces, tabs and newlines down to a single space, trims the whitespace inside tags, and removes HTML comments. Crucially, it recognises whitespace-sensitive elements: the contents of <pre>, <textarea>, <script> and <style> are copied through byte-for-byte, so preformatted text stays formatted and your inline scripts and styles keep working exactly as written.

The comment remover is smart about Internet Explorer conditional comments (<!--[if …]>), which it preserves because they carry real logic, while stripping ordinary explanatory comments. A single space is kept between elements so that spacing between inline elements such as links and spans is not lost. Everything runs locally in your browser with client-side JavaScript, so your HTML is never uploaded, logged or stored, and the tool works offline once loaded.

Frequently asked questions

Will minifying break my page layout?

It should not. The tool keeps a single space between elements so inline spacing is preserved, and it never touches the contents of pre or textarea, where whitespace is significant. If you have unusual whitespace-dependent CSS, compare the before and after and turn off Collapse whitespace if needed.

Are my inline scripts and styles preserved?

Yes. The contents of <script> and <style> blocks are passed through unchanged, so your JavaScript and CSS still run and apply correctly. To also compress them, run them through our CSS Minifier and JavaScript Minifier first.

Does it keep conditional comments?

Yes. Comments that begin with <!--[if (and the matching <![endif]-->) are preserved because they are used to target specific browsers. Only regular comments are removed when the option is enabled.

Is my HTML uploaded to a server?

No. All processing happens inside your browser. Nothing you paste leaves your device, so the tool is safe for private templates and unpublished pages, and it keeps working with no internet connection once loaded.