↑↓ to navigate Enter to open Esc to close

HTML Minifier

Strip comments and unnecessary whitespace from HTML to reduce its size. This one deliberately leaves <pre>, <textarea>, <script> and <style> blocks untouched, because collapsing whitespace inside those is how naive minifiers break pages.

HTML Minifier

Live
Original
0 B
Saved
0 B (0%)
Runs entirely in your browser. Always test minified output before replacing a live file.

What it removes - and what it protects

RemovedLeft alone
HTML commentsEverything inside <pre>
Repeated spaces, tabs, newlinesEverything inside <textarea>
Whitespace between tags<script> and <style> contents
Leading and trailing spaceConditional comments, if you keep them

Those four protected cases are the ones that matter. Whitespace inside <pre> and <textarea> is content - collapsing it visibly changes what the user sees. And a minifier that reformats JavaScript without parsing it will eventually break on a regular expression or a template literal containing something that looks like a tag.

⚠️ Where minifying HTML changes rendering

Collapsing whitespace between tags is safe for block elements and unsafe for inline ones. HTML renders a run of whitespace between two inline elements as a single space, so removing it entirely can join words together:

<span>Hello</span> <span>world</span> → renders as "Hello world" <span>Hello</span><span>world</span> → renders as "Helloworld"

If your output looks squashed after minifying, turn off Collapse space between tags. You lose a little compression and keep the layout, which is almost always the better trade.

Is minifying HTML actually worth it?

Honestly, less than most tutorials suggest - and the reason is compression. Every modern server sends HTML with gzip or Brotli compression enabled, and those algorithms are extremely good at collapsing repeated whitespace. Minifying first typically adds only a small further saving on top.

Where it does earn its place: HTML you're embedding somewhere that isn't compressed, email templates, inline snippets inside another document, or a page you're serving from a system you don't control. And it's genuinely useful as a one-off cleanup when you've inherited a file full of dead commented-out markup.

What actually moves page-load numbers is elsewhere: image sizes, render-blocking resources, and the number of third-party scripts. If HTML minification is your next optimisation, the bigger wins are usually still available.

Common mistakes

Minifying your only copy. The process is not reversible - comments are gone and formatting is unrecoverable. Keep the readable source as the file you edit, and treat minified output as a build artifact.
Assuming it replaces gzip. Server compression does most of the work and applies to every response automatically. If compression isn't enabled on your host, turning it on will save far more than minifying ever will.
Stripping conditional comments. They look like ordinary comments but are instructions to older browsers. If your markup still includes any, keep them - this tool has an option for exactly that.
Pushing minified HTML straight to production untested. Whitespace changes are visual and easy to miss in a diff. Load the result in a browser and compare it side by side with the original before it goes live.

Frequently asked questions

How much size will I actually save?

It depends entirely on how the source is formatted - deeply indented markup with lots of comments compresses much further than already-compact output. The counter above shows your real figure. Bear in mind the saving over gzip is smaller than the raw percentage suggests, since compression was already handling much of that whitespace.

Will this break my JavaScript or CSS?

No - <script> and <style> blocks are extracted before minification and restored untouched afterwards. That's a deliberate choice: minifying JavaScript correctly requires parsing it, and tools that use pattern matching instead eventually corrupt a regular expression or template literal. Use a dedicated JS minifier for that.

Is anything I paste uploaded?

No. Everything happens in JavaScript in your own browser, with no server request and nothing stored. That matters here more than in most tools, since HTML you're minifying may contain API keys, internal URLs, or unpublished content.

Can I un-minify the result?

A formatter can re-indent it so it's readable again, but the original comments are permanently gone and the exact original formatting can't be recovered. Always keep your source file - minified output should be something you can regenerate, never something you edit.

Should I minify HTML on a WordPress or Blogger site?

On platforms that generate HTML dynamically, a caching plugin or the platform itself usually handles this, and doing it by hand isn't practical since the markup is rebuilt on every request. This tool is more useful for static files, email templates, and snippets you paste into a page.

Does minifying HTML help SEO?

Only indirectly, and only slightly. Page speed is a ranking signal, but HTML size is rarely the bottleneck once server compression is on. Image weight, render-blocking scripts, and server response time move the numbers far more. Treat minification as tidying rather than as an SEO tactic.

Related tools

See the full list of Generators, or try: