HTML Minifier

Compress HTML by removing unnecessary whitespace and comments to reduce page weight.

📐 How to Use

  1. Paste your HTML into the input box.
  2. Click "Minify" to compress it.
  3. Copy or download the minified output.

🎯 When to Use This

  • Inlining a fragment of markup into a JavaScript string or a JSON field, where every newline would otherwise have to be escaped.
  • Stripping developer comments out of markup before it goes to a client preview, so internal notes and dead ideas do not ship.
  • Cutting the size of an email template, since many mail clients do not negotiate compression and raw bytes are what arrives.
  • Checking how much of a hand-written page is formatting, by reading the before and after character counts it reports.

❓ Frequently Asked Questions

QDoes minifying break inline JavaScript?
This tool preserves the content of <script> and <style> blocks without altering their internal syntax, only trimming surrounding HTML whitespace.
QIs minified HTML harder to debug?
Yes — keep a readable source version for development and only minify as part of your production build/deploy process.
QWill minifying affect SEO?
No — search engines parse the rendered DOM, not raw formatting. Minification can slightly help page speed, which is a minor ranking factor.

ℹ️ About This Tool

Most of the weight an HTML document carries beyond its text is indentation, blank lines and comments. The honest caveat is that transport compression already handles repetitive whitespace well, so a gzipped page shrinks far less than the raw character count suggests. Minification still earns its place where compression is not available, where markup is being inlined into another file, or where the comments themselves should not ship to the public.

The passes here run in a fixed order. Script and style blocks are set aside untouched first, so nothing inside them is altered. Comments are then removed, newlines and the indentation following them are deleted, whitespace between two tags is dropped, and any remaining run of two or more spaces becomes one. The protected blocks go back last. The result is reported with the character count before and after and the percentage saved.

⚠️ Notes & Limits

  • Whitespace between tags is removed, which deletes the rendered space between adjacent inline elements and can push two words together.
  • pre and textarea are not protected, so their contents are collapsed along with everything else. Keep those blocks out of the input.
  • Comment removal is unconditional and includes downlevel conditional comments, so a page still relying on IE conditional blocks will lose them.
  • Script and style contents are preserved exactly rather than minified, so inline CSS and JavaScript keep whatever size they arrived with.