HTML minifier

Paste HTML to get a smaller version instantly, with the byte saving shown.

What this minifier does

Removes HTML comments (except conditional comments), collapses runs of whitespace to a single space and removes whitespace between tags. Content of <pre>, <textarea>, <script> and <style> is left exactly as written. Removing space between inline elements can join words, so check inline layouts.

Is minification worth it?

Minification typically trims 10–40% of a text file. With gzip or Brotli compression on the server the gain shrinks, because compression already removes repetition, but minified files still compress slightly smaller and parse a little faster.

Other minifiers

CSS minifier · JavaScript minifier

Frequently asked questions

Can minified code be reversed?
Formatting can be restored with a formatter, but removed comments are gone. Keep your original source files.
Will it break my code?
The rules are deliberately conservative. Still, test the result, especially with unusual syntax.