HTML Minifier

Client-side HTML minification with live output and byte-savings stats.

HTML minification in your browser. Paste HTML, get minified output. Client-side; nothing sent to a server. How to use ↓·Shortcuts ↓
Paste HTML, get minified output.
Samples:
HTML Input
Minified Output
Minified output will appear here.
Input: 0 bytesOutput: 0 bytesSaved: 0 bytes · 0%

How to use

Paste HTML into the input pane. The minified output appears on the right as you type (300ms debounce).

Toggle options to control what gets stripped: whitespace, comments, attribute quotes, empty attributes. Inline <style> and <script> blocks can be minified in place.

Keyboard shortcuts

Two shortcuts:

Cmd / Ctrl + KFocus the input pane
Cmd / Ctrl + EnterCopy output to clipboard

When to use it

HTML minification saves bytes on static pages, email templates, and generated markup.

  • Prepping a static HTML file for a CDN drop without a build pipeline.
  • Cleaning up template output to see the actual bytes shipped.
  • Compressing HTML email templates before sending.
  • Quickly checking how small a snippet becomes.

When not to use: If you have a build pipeline (Next.js, webpack, Vite), it already minifies HTML output in production. This tool is for one-offs.

Options

Collapse whitespace — runs of spaces, tabs, and newlines become a single space. Off preserves formatting exactly.

Remove comments — strips all HTML <!-- ... --> comments. Conditional comments (<!--[if IE]>) are also removed.

Unquote attrsclass="foo" becomes class=foo when the value contains no special chars.

Remove empty attrs — drops attributes with empty string values.

Minify CSS — collapses whitespace and comments inside <style> blocks.

Minify JS — same for <script> blocks. Uses terser internally.

Format-specific gotchas

Whitespace can be meaningful. Inside <pre> and <textarea>, whitespace is preserved automatically. Between inline elements (<span>A</span> <span>B</span>), the space you rendered may matter — collapse can change layout. Test after minifying.

Attribute quotes matter more than they look. The tool only unquotes values that are safe to unquote. Values with spaces, quotes, or reserved chars stay quoted.

Conditional comments go too. If you need <!--[if IE]>-style comments for legacy browsers, turn off "Remove comments."

The library loads on first use. The minifier is dynamic-imported, so the first minify has a brief delay while it downloads. Subsequent runs are instant.

Privacy

Everything runs in your browser. Your HTML never leaves the page — no server, no logging, no analytics on the content.

Frequently asked questions

What does HTML minification do?
Removes whitespace, comments, and unnecessary attribute quotes. Optionally minifies inline CSS and JS. The resulting HTML renders identically but is smaller.
Will minification break my page?
Rarely, but whitespace between inline elements can affect layout. Test the minified output before shipping if you rely on whitespace formatting.
What are safe attribute values to unquote?
Values with no spaces, no quotes, and no HTML-reserved characters. The tool checks and leaves values quoted when unquoting would break parsing.
Does it minify inline CSS and JS?
Yes, if the options are on. Inline <style> content is minified as CSS; inline <script> content is minified via terser.
Why does the first minify take a moment?
The library loads on demand. First minify triggers the download; subsequent runs are instant.
Does the tool send my HTML anywhere?
No. All minification happens in your browser. The input never leaves the page.