HTML Minifier

Paste HTML, get a smaller version. The minifier collapses whitespace between tags, removes HTML comments, drops optional closing tags where the spec allows, and (optionally) minifies inline <style> and <script> blocks. Preserves whitespace inside <pre>, <code>, <textarea>, and <script> contents.

How to use the HTML Minifier

Paste your HTML and click Minify. The minifier removes comments, collapses runs of whitespace between block-level tags to single newlines (or nothing), and optionally drops unnecessary attribute quotes. Whitespace-sensitive elements (pre, code, textarea, script, style) are preserved exactly, so code blocks and form values don’t get mangled.

The conservative toggle keeps a single space between inline elements so words don’t run together. Turn it off for the maximum compression (which can cause spacing issues in rendered output if you have inline elements separated only by whitespace).

About HTML Minifier

HTML minification is a common production-build step. Typical hand-written HTML has 20-40% whitespace overhead from formatting; minifying recovers all of that. Bigger wins come from also minifying inline CSS / JS, dropping unnecessary attribute quotes (type="text"type=text where the value has no special characters), and dropping optional tags (HTML 5 allows omitting closing </li>, </p>, </td>, etc. in many contexts).

The trade-off is debuggability. Minified HTML is harder to read in the View Source panel, so most teams minify only in production builds. For server-rendered HTML, on-the-fly minification at the response layer (mod_pagespeed for Apache, ngx_http_pagespeed for Nginx) gives the wins automatically without changing your templates. For static sites, run a minifier as part of the build.

Common use cases

  • Pre-deployment static-site optimisation — minify HTML before uploading to a CDN.
  • Email HTML — every byte matters when sending millions of emails; minify your transactional templates.
  • Server-rendered page sample — paste a server response, see how much smaller it could be with minification at the proxy layer.
  • AMP pages — minified HTML is required for the AMP cache to serve fast.

Frequently asked questions

Will it break my page layout?

Conservative mode preserves the meaningful whitespace between inline elements. The other modes can collapse spaces that affect rendering \xE2\x80\x94 turn off if you see layout drift.

What about script tags?

Inline <script> contents are preserved exactly. Use our JS Minifier separately if you want to minify them.

Does it work for HTML emails?

Yes \xE2\x80\x94 with two caveats: turn off attribute-quote dropping (some email clients are picky), and verify the output renders correctly in your target clients before mass send.