How to Minify HTML in Your Browser
Paste Your HTML
Copy the markup from your page, template, or email and paste it into the Input HTML box. The tool runs entirely in your browser, so the markup stays on your device and is not uploaded anywhere.
Click Minify HTML
Press the Minify button. The tool strips standard comments, collapses runs of whitespace into single spaces, and removes the gaps between tags. The size summary shows the original bytes, the minified bytes, and the percent saved.
Copy or Clear
Use Copy Result to place the minified output on your clipboard, then paste it into your build, CMS, or deployment. Use Clear to empty both boxes before starting again with new markup.
What This Minifier Changes
This tool applies a focused set of text transformations to your markup. It does not rewrite attributes, remove optional tags, or touch script and style contents. The table below shows exactly what each pass does so you know what to expect from the output.
| Action | What Happens | Effect on Output |
|---|---|---|
| Comment removal | Standard HTML comments are deleted | Smaller file, hidden notes gone |
| Conditional comments | IE conditional comments starting with [if are kept | Legacy targeting preserved |
| Whitespace collapse | Tabs, newlines, and repeated spaces become one space | Fewer bytes, single line output |
| Tag spacing | Whitespace between adjacent tags is removed | No gaps between elements |
| Edge trimming | Leading and trailing whitespace is stripped | Clean start and end |
| Attribute values | Left untouched by name | Quotes and values unchanged |
When to Use HTML Minification
Shipping to Production
Minify static pages, partials, and templates before deploying so visitors download fewer bytes. The size summary helps you confirm the reduction is worthwhile for the file.
Email Markup
HTML email clients count every byte, and Gmail can clip large messages. Stripping comments and whitespace keeps newsletter markup lean before you send.
Keep Working Files Readable
Do not paste your source files back over themselves. Keep indented, commented copies for editing and minify only the version you publish.
When to Skip It
If your build pipeline already minifies output, or the page relies on whitespace-sensitive content, run a quick test before adopting the minified result.
Common Problems and Fixes
Spacing between words disappeared
The tool collapses whitespace between tags to nothing, which can join inline elements such as links or spans. If words run together, add a single non-breaking space or keep those elements on the same line in your source.
Content inside pre or textarea changed
This minifier collapses whitespace everywhere, including inside pre, textarea, and code blocks where spacing matters. Keep those sections out of the minified markup or re-add their original formatting afterward.
A comment I needed was removed
Only IE conditional comments that begin with [if are preserved. Other comments, including template markers and license notes, are stripped. Move anything you must keep out of HTML comments.
Copy button did nothing
The copy action uses the clipboard API, which needs a secure context and clipboard permission. If nothing copies, select the output text manually and copy it, or reload the page over HTTPS and try again.