Loading ToolDeck, please wait.

ToolDeck.online

INITIALIZING_

0%
DESIGNED BY SJ VISUAL FLOW STUDIOS
ToolDeck.onlineOpen. Build. Go.
Skip to content

HTML Minifier: shrink any HTML in your browser

Collapse whitespace, strip comments and minify inline CSS and JS. See exactly how many bytes you saved before you ship. Everything runs in your browser, and your HTML never leaves your device. No upload, no sign-up, no tracking.

  • Safe defaults on
  • Preserves pre, script, style
  • Byte savings report
  • Works offline
Minify optionsSafe by default. Nothing runs off-device.
HTML input0 chars, 0 B
Minified HTML0 chars, 0 B

Output updates live. Nothing is sent to a server.

  • Runs in your browser
  • No upload
  • No sign-up
  • Byte savings report
  • Safe defaults
  • Works offline

Related tools

Free developer and text tools that run in your browser. Nothing uploaded, ever.

See all ToolDeck tools

How this compares to other HTML minifiers

Most online HTML minifiers send your markup to a server. This one runs locally in your browser. Same output, no upload.

FeatureTToolDeckBuild pluginsTypical online tools
Runs entirely in your browserYesPartialNo
HTML never sent to a serverYesPartialNo
No sign-up or accountYesYesNo
Collapse whitespaceYesYesYes
Strip HTML commentsYesYesYes
Minify inline CSSYesPartialYes
Minify inline JSYesPartialYes
Byte savings reportYesPartialNo
Free without paywallsYesYesPartial
Works offline after page loadsYesNoNo

Comparison reflects publicly available information at the time of writing. Features may change.

How it works

  1. 1

    Paste your HTML

    Drop any HTML into the left pane. Full documents, fragments, email templates and template syntax like Handlebars or Nunjucks all work.

  2. 2

    Pick your options

    Choose which transforms to apply. Safe defaults are on. Aggressive options like inline JS minification are off until you enable them.

  3. 3

    Copy or download

    Copy the minified HTML to your clipboard or download it as a .html file. The size report shows exactly how much you saved.

Everything you get for free

  • Whitespace collapse

    Trims runs of spaces, tabs and newlines between tags and inside text. Content inside pre, textarea, script and style is preserved byte for byte.

  • Comment removal

    Deletes HTML comments (<!-- ... -->). Conditional comments for old IE are detected and kept so legacy behaviour stays intact.

  • Inline CSS minification

    CSS inside <style> blocks gets comments removed, whitespace collapsed and semicolons before closing braces dropped. Same cascade, smaller payload.

  • Inline JS minification

    Conservative JS minifier for <script> blocks: strips line and block comments, collapses whitespace. Does not rename variables or drop semicolons.

  • Attribute cleanups

    Remove empty attributes (class="", id=""), collapse boolean attributes (checked="checked" to checked), optionally drop quotes on safe bare values.

  • Alphabetical attribute sort

    Optionally sort attributes within each tag. Useful for consistent output, better compression ratios and clean diffs between builds.

  • Live byte savings report

    See exact input size, output size, percentage saved and a gzip estimate so you know what you will actually ship.

  • Safe defaults

    Everything that could break a page is off by default: no HTML entity rewriting, no tag reordering, no script execution. You opt in to the aggressive settings.

What people use it for

  • Ship smaller HTML to users

    Strip kilobytes of whitespace and comments before deploying. Combined with gzip, HTML payloads drop 40 to 60 percent on typical pages.

  • Static site build step

    Run generated HTML from Hugo, Jekyll or Eleventy through the minifier before uploading to your CDN.

  • Email template cleanup

    Minify HTML email templates. Every saved kilobyte reduces the chance of Gmail or Outlook clipping your message.

  • CMS output tuning

    Some CMSes inject dozens of comments and whitespace into every page. Minify the rendered output before it hits your users.

  • Readable diffing

    Minify two versions of the same page then diff them. Whitespace noise disappears and real changes stand out.

  • Learning how minifiers work

    Toggle options one by one and watch the size report change. A quick way to understand what actually saves bytes.

Questions people ask

Is my HTML sent to a server?

No. The minifier runs entirely in JavaScript on your device. Your HTML, class names, inline content and any embedded secrets never leave your browser. Turn off wifi after the page loads and it still works.

Will minifying break my HTML?

The default options are safe for almost every page. They only remove whitespace between tags, strip comments, drop empty attributes and collapse boolean attributes. Aggressive options like inline JS minification are off by default because they can affect code that relies on comments or whitespace between statements.

Does it minify inline JavaScript safely?

The inline JS minifier is conservative. It strips line and block comments and collapses whitespace, but it does not rename variables, remove semicolons, reorder expressions or perform any AST-level transform. This is safe for the vast majority of scripts but not as small as a full minifier like Terser or esbuild.

Will it break conditional comments for old IE?

No. Downlevel-revealed and downlevel-hidden conditional comments (<!--[if IE]> ... <![endif]-->) are detected and left in place. Everything else is treated as a normal comment and removed if the option is on.

Does whitespace inside <pre> get collapsed?

No. Content inside pre, textarea, script and style tags is pulled out before any transform and restored byte for byte at the end. Whitespace and newlines in those tags are never touched.

Does it inline critical CSS?

No. The tool minifies CSS that is already in a <style> block. It does not extract, merge or inline external stylesheets. For critical CSS inlining, use a build-time tool like critical or critters.

Does it rewrite or reorder tags?

No. The minifier never moves, adds or removes elements. It only edits attribute-level details and whitespace. The DOM structure after minification is identical to the original.

How much smaller does the output get?

On typical static HTML with plenty of indentation, 15 to 35 percent reduction on the raw file. After gzip, real-world savings on the wire are usually 3 to 10 percent because gzip already handles whitespace well. Comments and repeated class names are where gzip has less leverage, so stripping them helps more.

Does it support template languages like Handlebars?

Yes. Curly braces, percent tags and similar template syntax pass through untouched because the minifier only looks at tag structure and attribute values. Handlebars {{#if}}, Nunjucks {% raw %} and similar work fine.

Does it support SVG and MathML?

Inline SVG and MathML are treated as normal tags, so whitespace collapse and comment removal apply. But whitespace inside <text> and <tspan> elements in SVG can be significant. If your SVG relies on significant whitespace, keep the collapse option off.

Can I undo a minification?

No. The tool does not keep a copy of the original after you paste new content. If you want to compare, keep the original HTML in a separate file. The size report is derived from what is currently in the input pane.

Is there a size limit?

No hard limit. Documents up to a few hundred KB minify instantly. Very large single-page HTML (multiple MB) may take a second or two because of the regex passes.

Can I use this for commercial work?

Yes. There are no restrictions on the output. Whatever rights you hold over the source, you keep over the minified result. The tool does not add watermarks or tracking.

Does it handle CSS in <style> with @media and keyframes?

Yes. CSS comments and whitespace are stripped while preserving all selectors, at-rules and declarations. Media queries, keyframes, custom properties and calc expressions are not rewritten.

Does it compress HTML entities?

No. Entities like &amp; and &nbsp; are left exactly as written. Some minifiers convert them to raw characters, but that can change rendering in unusual encodings, so this tool does not do it.

Can I automate this in a build pipeline?

Not with this tool. This is a browser-only minifier for manual use. For build pipelines, use html-minifier-terser, PostHTML or the built-in minification in Next.js, Astro, Vite and similar frameworks.

Your HTML never leaves your device

There is no upload step and no server-side handling. The minifier is a pure JavaScript function that runs in your browser tab. Your markup, class names, inline content and any embedded tokens stay on your computer. Open the browser network tab while using the tool and confirm there are no outbound requests carrying your HTML. Read how we keep it private.