KitJade
Developer ToolsRuns in your browserNew

HTML Minifier

Compress HTML without breaking inline code.

Use the HTML Minifier tool

Runs in your browserUpdated Report a problem

What this html minifier does

HTML Minifier removes HTML comments and repeated whitespace between tags, then reports the bytes saved. Content inside script, style, pre and textarea elements is preserved so that code samples and inline CSS or JavaScript keep working.

It is a conservative whitespace compressor, not an HTML optimiser: it does not remove unused CSS, rewrite attributes or inline assets. Always load the minified page and test it before replacing the original.

Why use it

  • Shrink static pages before deploying them.
  • Remove development comments from exported templates.
  • Check how much of a page is whitespace and comments.

How to use it

  1. 1Paste the HTML.
  2. 2Read the before/after byte counts.
  3. 3Copy or download the minified output.
  4. 4Open the result in a browser and check layout and scripts.

Worked examples

Comment removal

Input

<!-- header -->
<header>
  <h1>Title</h1>
</header>

Output

<header><h1>Title</h1></header>

Preformatted code

Input

<pre>  indented
  sample</pre>

Output

The indentation inside pre is kept.

Common mistakes

  • Treating the output as verified; whitespace can be significant between inline elements.
  • Minifying templates that rely on comments for server-side directives.
  • Expecting the tool to fix invalid HTML; it only removes whitespace and comments.

Frequently asked questions

Is whitespace ever significant in HTML?
Yes, between inline elements and inside preformatted content. The minifier preserves pre, textarea, script and style content, but check inline layouts.
Does it remove attribute quotes?
It removes optional quotes only where the value is unambiguously safe.
Will it break my JavaScript?
Script content is left untouched, but inline handlers written as attributes are part of the markup. Test interactive pages.
Is the HTML uploaded?
No. The transformation runs in this tab.
All tools