HTML Minifier
Shrink HTML payloads safely while leaving whitespace-sensitive blocks byte-identical.
Minify HTML instantly in your browser. Free HTML minifier removing comments and whitespace while protecting pre, script and style blocks.
Calculator Inputs
About Minify HTML
Shrink HTML payloads safely while leaving whitespace-sensitive blocks byte-identical.
Paste markup to remove comments and collapse inter-tag whitespace and blank lines. Crucially, pre, textarea, script, and style contents are stashed untouched — collapsing those would corrupt code samples, forms, and scripts.
Conditional IE comments are preserved as well. Byte counts prove the saving; pair with gzip for the real win. Everything runs in your browser.
Where it is used
Pre-deploy optimization, email HTML slimming, auditing template bloat, and teaching minification.
How to use the Minify HTML
- HTML Source — enter the value (e.g. <!-- header --> <div> <p>Hello</p> </div>).
- Calculate — press the Calculate button to see the result instantly above.
Formula
Stash pre/textarea/script/style → strip comments → collapse inter-tag whitespace → restore.
Examples
Example
Frequently Asked Questions
- Why protect pre and textarea?
- Their whitespace is content: collapsing it changes rendered text and editable defaults. A naive minifier corrupts them silently.
- Does it remove quotes around attributes?
- No — unquoted attributes break on values containing spaces or special characters, so quotes stay. The saving would be tiny anyway.
- Minify or gzip — which matters more?
- Gzip, by far. Minify first for 10–25%, then gzip for another 60–80% on top.