Free online text tool

Remove HTML Comments

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.

Remove HTML Comments

0Character Count
0Character Count (without spaces)
0Word Count
0Sentence Count
0Paragraph Count
0Line Count

Remove HTML Comments Example

Before
<!-- the comment --> There are few things better in life than a slice of pie.
After
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.

Suggest a New ToolProvide Feedback on This Tool

What does Remove HTML Comments do?

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.

Remove HTML comments examples

Each example shows the text before and after. The clean-up option is on unless the example says otherwise.

CaseBeforeAfter
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>

How to remove HTML comments

  1. 1
    Add your code or text
    Paste your HTML or text into the box, or import a text file.
  2. 2
    Choose the option
    Leave Also remove the spaces and empty lines left behind ticked for a clean result, or untick it to remove only the comments.
  3. 3
    Click Remove HTML Comments
    All the comments are removed at once. Use Undo if you change your mind.
  4. 4
    Copy it
    Click Copy and paste the result where you need it.

When to remove HTML comments

Good for

Cleaning up a page before you publish it, making an HTML file smaller, and taking notes and old code out of a template.

Check first

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.

Other tools

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.

Remove HTML comments FAQ

What does the Remove HTML Comments tool do?

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.

How do I remove HTML comments?

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.

Does it remove comments that go over several lines?

Yes. A comment that starts on one line and ends on a later line is removed completely, including everything inside it.

What happens to the space or the line where the comment was?

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.

Does it remove conditional comments for Internet Explorer?

Yes. Conditional comments such as <!--[if IE]> ... <![endif]--> are written as HTML comments, so they are removed too.

What if a comment is never closed?

A comment with no --> at the end is left as it is, because there is no way to know where it stops.

Does it change comments inside script or style tags?

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.

Does it remove CSS or JavaScript comments?

No. Only HTML comments are removed, not /* ... */ or // comments.

What if there are no comments?

Your text is left as it is and you see the message No HTML comments found.

Is this tool free and is my code private?

Yes. It is free, needs no account and runs in your browser, so your code is not uploaded to a server.

Looking for more text tools?

Browse Remove Tools

Last updated: 11 November 2026