Minify HTML before shipping it

Indented, commented source is for humans. The shipped copy can drop the whitespace and commentary without changing what renders.

Tools used in this guide

The job

Pretty HTML pays a tax on every request — indentation inside templates, comments nobody reads in production. A minifier removes the bytes that never reach the eye while leaving markup semantics untouched.

How to do it

Paste the HTML and minify; the tool reports byte size before and after. Copy the result or download the .html.

  • Whitespace between block-level elements disappears; a single space is kept between inline elements so words do not fuse.
  • Script, style, pre and textarea contents pass through untouched — whitespace there is meaningful.

Worked example

A 280-byte hand-formatted page with a comment block minifies to 205 bytes — the same DOM, minus the commentary and the indentation between layout elements.

Limits

This is conservative minification — no attribute rewriting, no class-name shortening, no JavaScript mangling. Conditional comments for old IE are kept. Pages that rely on `white-space: pre` styled elements may still shift; keep those as pre/textarea or test before shipping.