Remove HTML Comments deletes all the comments from your HTML source code or text. Paste your code, click the button and copy the result. It is free and runs in your browser.
<!-- the comment --> There are few things better in life than a slice of pie.
There are few things better in life than a slice of pie.
Bookmark: press Ctrl+D (Windows) or Cmd+D (Mac) to save this tool.
This tool removes all HTML comments from your source code or text. An HTML comment starts with <!-- and ends with -->, and everything between them is deleted, even when the comment goes over several lines.
By default it also cleans up what the comments leave behind. A line that only held a comment is removed, and the spaces next to a comment are removed too. Your indentation is kept. Untick the option if you want to remove only the comments.
Use it before you publish a page, to shrink an HTML file, or to take notes and old code out of a template.
Each example shows the text before and after. The clean-up option is on unless the example says otherwise.
| Case | Before | After |
|---|---|---|
| Example | <!-- the comment --> There are few things better in life than a slice of pie. | There are few things better in life than a slice of pie. |
| A comment on its own line | <h1>Title</h1> <!-- menu --> <p>Text</p> | <h1>Title</h1> <p>Text</p> |
| A comment at the end of a line | <p>Hello</p> <!-- end hello --> | <p>Hello</p> |
| A comment in the middle of a line | <p>Hello <!-- note --> world</p> | <p>Hello world</p> |
| A comment over several lines | <div> <!-- old menu <ul></ul> --> </div> | <div> </div> |
| Indentation is kept | <ul>
<!-- item --> <li>One</li>
</ul> | <ul>
<li>One</li>
</ul> |
| Several comments on one line | <!-- a -->one<!-- b -->two | onetwo |
| Clean-up option off | <p>a</p> <!-- x --> <p>b</p> | <p>a</p> <p>b</p> |
| A comment that is never closed | <p>a</p> <!-- never closed | <p>a</p> <!-- never closed |
| No comments | <p>Hello</p> | <p>Hello</p> |
Cleaning up a page before you publish it, making an HTML file smaller, and taking notes and old code out of a template.
Everything between the start and the end of a comment is deleted, even code. A comment that is never closed is left as it is. The tool also removes comment-like text inside script, style and pre tags. The result replaces your text, so use Undo if you need the original.
To remove HTML tags too try Remove Html Tags. To make the code easy to read try Html Beautifier. To remove empty lines try Remove Empty Lines.
It removes every HTML comment, the parts that start with <!-- and end with -->, from your source code or text. Everything outside the comments stays as it is.
Paste your HTML or text into the box and click Remove HTML Comments. The comments are removed. Click Copy to use the result, or Undo to go back.
Yes. A comment that starts on one line and ends on a later line is removed completely, including everything inside it.
By default the tool also cleans up what a comment leaves behind. A line that only had a comment is removed, and the spaces next to a comment are removed. Your indentation is kept. Untick the option to remove only the comments themselves.
Yes. Conditional comments such as <!--[if IE]> ... <![endif]--> are written as HTML comments, so they are removed too.
A comment with no --> at the end is left as it is, because there is no way to know where it stops.
The tool works on text and does not understand your code, so it removes anything that looks like an HTML comment, even inside script, style or pre tags. Check the result if you have such code.
No. Only HTML comments are removed, not /* ... */ or // comments.
Your text is left as it is and you see the message No HTML comments found.
Yes. It is free, needs no account and runs in your browser, so your code is not uploaded to a server.
Last updated: 11 November 2026