Browser-local markup utility

HTML Minifier

Shrink HTML without gambling on hidden transformations. Start conservatively, inspect exact byte savings and warnings, then copy or download the result.

Your HTML stays in this browser

Minify HTML

Best first pass: removes eligible comments only.
Conditional, license, server/framework directive, bang, and htmlmin: comments are always kept.
HTML only, up to 1 MiB.
0 characters · 0 B
Maximum 1,000,000 characters and 1 MiB of UTF-8. Ctrl/Cmd+Enter runs the minifier.
No result
Output is plain text. This page never renders or executes your markup.
Ready. Conservative mode leaves every whitespace character untouched.

Choose the smallest safe change

Conservative

Leaves whitespace untouched and only removes ordinary comments when enabled. Start here for templates, email HTML, components, or unfamiliar code.

Collapse

Turns each run of ordinary ASCII whitespace into one space outside protected contexts. It keeps separators between inline elements, but CSS can still make the change visible.

Compact

Also removes whitespace-only text nodes between tags. This saves more indentation but may join inline content. Render-test the exact output before deployment.

How to use the result

  1. Paste HTML or choose a local file, then begin with the Conservative profile.
  2. Read the byte total and every review note. If you need more savings, try Collapse before Compact.
  3. Compare and render-test the output on the browsers and email clients your project supports. Minification is not HTML validation.
  4. Copy or download only after the result matches your application. Keep the readable source in version control.

The byte figures use UTF-8, so they reflect multibyte characters more accurately than a JavaScript character count. A smaller HTML source may reduce transfer size, but HTTP compression can change the real network savings.

What is preserved

The tokenizer keeps the contents of script, style, pre, textarea, title, template, legacy raw-text containers, noscript, SVG, and MathML byte-for-byte. It also keeps PHP/processing-instruction, ASP, Mustache, Twig statement, and Twig comment fragments. Functional conditional comments, license/preserve comments, bang comments, and htmlmin: directives are never stripped.

This deliberately excludes optional-tag removal, attribute quote removal, attribute sorting, entity decoding, and inline CSS or JavaScript minification. Those transformations need a production-grade parser and project-specific tests. Unterminated protected constructs cause an error rather than a guessed output.

Important limitations and privacy

Whitespace is observable data. Inline-element spacing, white-space CSS, contenteditable, custom elements, templating engines, hydration markers, XML/XHTML, and email clients can all make an apparently small edit matter. The tool warns about signals it can see, but it cannot know computed styles, runtime DOM changes, server-side template behavior, or rendering in every client.

Processing is stateless and occurs entirely in your browser. No markup is uploaded, fetched from a URL, stored in a cookie, or written to local storage. The local file picker reads only the file you select. The HTML Living Standard distinguishes normal, raw-text, escapable raw-text, and foreign content and makes optional-tag removal context-sensitive; these rules are why the defaults favor preservation.