Skip to content
snip tools

HTML minifier

Strip comments and formatting whitespace to shrink HTML. Runs entirely in your browser.

Runs 100% in your browser
 

How to minify HTML

  1. Paste your HTML. Paste the markup you want to shrink.
  2. Minify. Comments and formatting whitespace are stripped instantly.
  3. Copy or download. Grab the minified HTML.

About HTML minification

HTML authored for humans is full of indentation and comments that browsers don't need. Removing them trims bytes off every page load. This minifier takes a careful approach — it strips comments and collapses formatting whitespace but preserves the contents of pre-formatted and code blocks and keeps meaningful spacing between inline elements — so the rendered result matches your source. For the inline CSS and JavaScript, run the CSS and JS minifiers.

Frequently asked questions

How does this minify HTML?
It removes HTML comments and collapses the formatting whitespace (indentation and line breaks) between and inside elements, while preserving the contents of <pre>, <textarea>, <script> and <style> so code and pre-formatted text are untouched.
Is it safe — will my page look the same?
It is deliberately conservative: it keeps authored single spaces between inline elements and never touches protected blocks, so rendering is preserved. It does not minify the JavaScript or CSS inside the page — use the JS and CSS minifiers for those.
Does it keep conditional comments?
Yes. Legacy IE conditional comments (<!--[if …]>) are preserved; ordinary comments are removed.
Is my HTML uploaded?
No. Everything runs in your browser.