HTML Comment Remover
Strip every <!-- comment --> from your HTML without breaking the page. Text that only looks like a comment — inside a <script>, a <style>, a <textarea> or an attribute value — is left exactly as it is.
Why Remove HTML Comments?
Comments are invisible on the page — but not in the source.
HTML comments (<!-- … -->) are notes for developers. Browsers don't display them, but they're still downloaded and anyone can read them with View Source. Old code, TODO notes, internal URLs and build information often end up there.
Removing them makes pages a little smaller and keeps internal details private. Unlike a simple search-and-replace, this tool reads HTML the way a browser does, so it only removes real comments.
What's protected. Inside <script> and <style> (and <textarea>, <title>, <xmp>, <iframe>, <noembed>, <noframes>), <!-- is just text — removing it could break JavaScript or CSS. The same goes for attribute values like title="<!-- -->", <![CDATA[ … ]]> blocks and <!DOCTYPE>.
Unclosed comments. A <!-- without a closing --> hides everything after it in a browser. The tool doesn't delete the rest of your document — it leaves that part unchanged and tells you the line number so you can fix it.
Comment Forms the Tool Understands
All of these follow the HTML standard.
| Form | What it is | Removed? |
|---|---|---|
<!-- note --> | Normal comment (may span lines) | Yes |
<!---->, <!-->, <!---> | Empty comments | Yes |
<!-- a --!> | Comment closed with --!> (browsers accept it) | Yes |
<!--[if IE]> … <![endif]--> | IE conditional comment | Yes, unless “Keep IE conditional comments” |
<!--! licence --> | “Important” comment convention | Yes, unless “Keep <!--! … -->” |
<script>// <!-- … --></script> | Script text, not a comment | Never |
<!DOCTYPE html>, <![CDATA[ … ]]> | Not comments | Never |
How to Use the HTML Comment Remover
Get your result in under ten seconds.
Paste your HTML
A snippet, a template or a whole page — or open a file.
Choose what to keep
IE conditional comments and <!--! licence comments are optional.
Copy the clean HTML
Everything except the comments is byte-for-byte unchanged.
Why Use the HTML Comment Remover on Developers Web Tools
Fast, accurate and private — built for developers.
Never breaks code
Scripts, styles, textareas and attribute values are skipped exactly like a browser does.
Standard-exact
Handles <!-->, <!---> and --!> endings defined by the HTML standard.
Selective
Keep IE conditional comments or <!--! licence notes if you need them.
Tidy output
Lines that held only a comment are removed, not left blank.
Unclosed comments
Reported with a line number instead of swallowing the rest of the page.
Private
Your markup never leaves the browser.
Frequently Asked Questions
No. <!-- inside <script> and <style> isn't an HTML comment, so it's left alone. The tool also skips attribute values, <textarea> and <title> content. Only real HTML comments are removed.
No — those are JavaScript and CSS comments. Removing them safely needs a JavaScript or CSS parser; use the CSS Minifier (and the upcoming JavaScript Minifier) for that.
Usually not. Only Internet Explorer 5–9 read them, and those browsers are long retired. Keep them only if you still support very old IE.
In a browser, an unclosed <!-- hides everything after it. The tool leaves that part of your document unchanged and shows the line number, so you can add the missing -->.
No. Apart from removed comments (and, if enabled, the empty lines they leave), the output is identical to your input.
No. Everything runs in your browser.