Where HTML comments pile up
Templates from CMSes, page builders, and design tools tend to leave a trail: section markers, "end of loop" notes, commented-out variants of a component nobody deleted. None of it renders, but it's still sitting in the file every time you open it.
Stripping it out makes the markup easier to read and a little smaller to ship, which matters more than it sounds like once a page has been through a few redesigns.
How HTML comments work
HTML only has one comment syntax: <!-- like this -->, which can wrap a single line or several. There's no equivalent to a line comment. Anything between those markers, including old conditional comments for Internet Explorer, gets removed. Everything outside them, tags, attributes, text, is left exactly as it was.
Frequently asked questions
Does it touch inline <script> or <style> blocks?
The HTML comments around your markup are removed. Comments written inside <script> (// or /* */) or <style> (/* */) tags use a different syntax, so use the JavaScript or CSS comment remover for those.
What about conditional comments like <!--[if IE]-->?
Those are still HTML comments as far as the parser is concerned, so they'll be removed too. If you're still supporting old IE hacks, keep a backup before running this.
Is this safe to run on a whole page, not just a snippet?
Yes, paste as much markup as you need. It only removes comment nodes; every tag, attribute, and text node stays exactly where it was.