Runs 100% in your browser — your HTML is never uploaded

HTML Minifier

Paste your markup and get compressed HTML in one click. Collapses whitespace, strips comments, tightens attributes and minifies inline CSS and JavaScript — with Safe, Balanced and Aggressive presets and a live size and gzip readout.

Minify HTML

HTML

Waiting for HTML

Minified

Nothing minified yet
Minification settings
Options tagged Care can change how the page renders; options tagged Risky can produce invalid markup or delete elements your scripts rely on. Always test aggressive output before deploying.

Original 0 B Minified 0 B Gzipped — Saved 0 B (0%)

In short: what this HTML minifier does

The SeeB4Coding HTML Minifier compresses HTML documents in your browser using html-minifier 4. Paste markup, pick a preset, and copy smaller HTML — no sign-up, no upload, no build step.

  • Three presets: Safe (whitespace and comments only), Balanced (adds inline CSS/JS minification and attribute cleanup) and Aggressive (adds quote removal, optional tags and inline whitespace collapsing).
  • 30 individual options covering whitespace, comments, attributes, tags, and inline CSS and JavaScript, each with a plain-English description and a risk tag.
  • Real numbers: original size, minified size, gzipped size and the percentage saved, recalculated on every run.
  • Inline assets: <style> blocks are minified with clean-css, <script> blocks with UglifyJS.
  • Beautify too: the same tool re-indents minified HTML back into readable code.
  • Copy anywhere: output as plain HTML, an escaped JSON string, or a JavaScript template literal.
  • Privacy: everything runs client-side in a Web Worker — your HTML never leaves the device.

How to minify HTML online

Three steps, about a minute.

Paste your HTML

Paste your markup, drop an .html file onto the editor, or load the sample document. With auto-minify on, the output updates as you type.

Pick a preset

Start with Balanced. Switch to Safe for templates and email HTML, or Aggressive for the smallest output, then fine-tune any of the 30 options.

Copy or download

Check the savings bar, then copy the minified HTML or download it as a file. Settings and your last 20 runs are remembered on this device.

What minification does to your markup

The same document before and after the Balanced preset. Nothing about the rendered page changes — only bytes the browser does not need.

Before

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- main stylesheet -->
    <meta charset="utf-8">
    <title>Pricing</title>
    <style type="text/css">
      .card {
        padding : 16px ;
        color   : #ffffff ;
      }
    </style>
  </head>
  <body>
    <div class="card" style="">
      <h1>Plans</h1>
    </div>
  </body>
</html>

341 bytes

After

<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Pricing</title><style>.card{padding:16px;color:#fff}</style></head><body><div class="card"><h1>Plans</h1></div></body></html>

191 bytes — 44% smaller

Five separate changes happened there: indentation between tags collapsed, the comment was dropped, type="text/css" was removed as redundant in HTML5, the CSS was minified and #ffffff shortened to #fff, and the empty style="" attribute was removed. Note that an empty data-* attribute would have been kept — only a safe list of attributes is dropped when empty.

Safe vs Balanced vs Aggressive

The presets differ in how much they are willing to change. Every one of them keeps valid, working HTML for ordinary pages; the risk climbs as you move right.

What each preset turns on.
Behaviour Safe Balanced Aggressive
Collapse whitespaceYesYesYes
Remove commentsYesYesYes
Short doctype, drop type on script/styleYesYesYes
Minify inline CSS and JavaScriptNoYesYes
Remove empty, redundant and boolean attribute valuesNoYesYes
Remove attribute quotesNoNoYes
Remove optional tags (</p>, </li>, <body>)NoNoYes
Collapse whitespace between inline elementsNoNoYes
Typical extra saving over Safe—2–6%4–10%
Best forEmail HTML, templates, whitespace-sensitive layoutsMost websites and web appsStatic pages you can test after minifying

Rule of thumb: ship Balanced. Reach for Aggressive only when the extra few kilobytes matter and you can load the page afterwards to confirm nothing shifted.

What each option actually does

The options that change the most bytes, and what they cost you.

Key html-minifier options exposed by this tool.
Option Effect Risk
collapseWhitespaceCollapses runs of whitespace in text nodes and removes it between block elements. Usually the single biggest win.Low
removeCommentsStrips <!-- --> comments. Conditional comments are kept unless you also process them.Low
minifyCSSRuns clean-css over <style> blocks and style attributes.Low
minifyJSRuns UglifyJS over <script> blocks and event handler attributes. ES5 only — modern syntax is left as-is.Medium
removeRedundantAttributesDrops attributes equal to their default, such as method="get" or type="text" on an input.Low
collapseBooleanAttributesTurns disabled="disabled" into disabled.Low
removeAttributeQuotesDrops quotes where HTML5 allows it. Valid HTML5, invalid XHTML, and confusing to regex-based tooling.Medium
removeOptionalTagsOmits tags the parser can infer, including <html>, <head>, <body> and closing </p>, </li>, </td>.Medium
collapseInlineTagWhitespaceRemoves the spaces between inline elements as well. That space is often visible text, so layouts can shift.High
removeTagWhitespaceRemoves spaces between attributes. Browsers cope, but the result is not valid HTML.High
removeEmptyElementsDeletes elements with no content — including the empty <div id="root"></div> your framework mounts into.High
conservativeCollapseCollapses whitespace to a single space instead of removing it. Use it when a layout depends on spacing.Low

Getting smaller HTML safely

A few habits that make minification pay off without surprises.

Minify the output, not the source

Keep your repository readable and minify at build or deploy time. Committing minified HTML makes every future diff unreadable for a few kilobytes.

Turn on gzip or brotli as well

Minification and compression stack. Compare the gzipped number here with your server's response size — that is what users actually download.

Watch inline elements

Whitespace between <a>, <span> and <button> tags is rendered text. If your spacing disappears, switch on conservative collapse.

Modernise or pre-minify inline JS

UglifyJS parses ES5. If you get the modern-syntax warning, move that script to an external file minified by your bundler.

Be careful with templates

<?php ?> and <% %> blocks pass through untouched, but whitespace around {{ }} expressions is collapsed like any other text.

Test the aggressive run

Minify, load the page, click through it once. Two minutes of checking is cheaper than debugging a layout shift in production.

Frequently asked questions

Everything people usually ask about minifying HTML.

Is my HTML uploaded to a server?

No. The minifier is JavaScript running in your browser, inside a Web Worker. Your markup never leaves your device, so pages containing API keys, customer data or unreleased content stay private. Once the page has loaded you can go offline and it keeps working.

How much smaller will my HTML get?

Typically 3 to 20 percent of the raw file, depending on how much indentation, commenting and inline CSS or JavaScript it contains. Hand-written and templated pages save the most; HTML that a build tool already processed saves the least. After gzip the gap narrows to a few percent, because gzip already compresses repeated whitespace well — which is why this tool shows both numbers.

Will minifying break my page?

The Safe and Balanced presets only make changes that keep the rendered result identical. The risk lives in the aggressive options: collapseInlineTagWhitespace can remove spaces that were visible text, removeTagWhitespace produces technically invalid markup, removeEmptyElements deletes containers such as an empty app mount point, and preventAttributesEscaping can break values containing quotes. Each of those is tagged in the settings panel.

Does it minify inline CSS and JavaScript too?

Yes. <style> elements and style attributes go through clean-css; <script> elements and inline event handlers go through UglifyJS. UglifyJS parses ES5, so inline scripts using const, let, arrow functions or async are passed through unchanged instead of being broken, and a warning appears under the tool when that happens.

What does "remove optional tags" do?

The HTML specification lets you omit tags a parser can infer — <html>, <head>, <body>, and the closing </p>, </li>, </tr> and </td>. With the option on, a list becomes <ul><li>a<li>b</ul>. Browsers render it identically, but the source is harder to read and strict downstream parsers may object.

Is removing attribute quotes safe?

Quotes are only dropped when the value contains no spaces, quotes, equals signs or angle brackets, so every browser still parses it correctly. It is valid HTML5 but not valid XHTML, and it can confuse regex-based parsers, template linters and some email clients — which is why it belongs to the Aggressive preset rather than the defaults.

Should I still minify if my server already uses gzip or brotli?

Yes, but expect modest gains. Compression already handles repeated whitespace efficiently, so minifying first usually saves a few extra percent on the wire. It also cuts the bytes the browser has to parse, which matters on large documents and slow devices. Minification and compression are complementary, not alternatives.

Can I minify PHP, Jinja, Handlebars or Angular templates?

PHP and ASP style blocks — <?php ... ?> and <% ... %> — are preserved untouched by default. Handlebars, Jinja and Angular expressions such as {{ name }} survive because they are ordinary text, but the whitespace around them is collapsed like any other text node, which matters if your template relies on it. Enable conservative collapse to keep a single space, and always check the rendered result.

How do I unminify or beautify HTML?

Use the Beautify button above the input panel; it re-indents minified markup with js-beautify. Minification is lossy for comments and formatting, so beautifying restores structure and indentation but cannot bring back comments that were removed.

What is the "JSON" output tab for?

It escapes the minified HTML into a valid JSON string, quotes included, ready to paste into an API payload, a config file or a test fixture. The JS tab does the same as a JavaScript template literal, escaping backticks and ${ so the string is safe to drop into code.

Is there a file size limit?

No hard limit. Minifying happens in a Web Worker so the page stays responsive, but documents over a few megabytes take noticeably longer and auto-minify switches itself off above 300 KB to keep typing smooth.

Is the HTML Minifier free?

Yes. Completely free, no sign-up, and no limit on how many documents you minify.

Other browser-based utilities from SeeB4Coding.