HTML comment remover

Remove comments from
HTML code.

Strip <!-- HTML comments --> from .html and .htm files online. Preserves DOCTYPE, conditional comments, and attribute values exactly.

Free, no signup Runs in your browser Instant, no upload Works on .html files

Before and after

Real-world HTML code on the left. The same code with every comment removed on the right.

html-input.html
<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Title block -->
  <meta charset="utf-8" />
  <title>Acme Orders</title>
  <!--[if lt IE 9]>
    <script src="legacy.js"></script>
  <![endif]-->
</head>
<body>
  <!-- Main content -->
  <main>
    <h1>Orders</h1>
    <!-- TODO: hook up real data -->
    <ul>
      <li>Order #1</li>
      <li>Order #2</li>
    </ul>
  </main>
</body>
</html>
html-output.htmlcleaned
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Acme Orders</title>
</head>
<body>
  <main>
    <h1>Orders</h1>
    <ul>
      <li>Order #1</li>
      <li>Order #2</li>
    </ul>
  </main>
</body>
</html>
Why use it

Built for HTML specifically.

HTML files frequently carry build-tool comments, debugging hints, and content management system markers. Removing them shrinks page weight, hides implementation details from view-source snoops, and produces cleaner output for static-site builds. Uncommenter strips every <!-- ... --> block while leaving your tags, attributes, and DOCTYPE alone.

  • <!-- comments --> removed across single and multiple lines
  • DOCTYPE and tag structure preserved
  • Attribute values containing <!-- preserved
  • Inline <script> and <style> blocks preserved (use the JS/CSS pages to clean those)
  • Auto-detected from .html and .htm files
How it works

Strip comments in 30 seconds.

  1. 1

    Open the tool

    Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.

  2. 2

    Paste your HTML code

    Drop your .html file in, or paste code into the editor. Auto-detection picks up HTML from the extension or file content.

  3. 3

    Click 'Remove Comments'

    The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.

  4. 4

    Copy or download

    Grab the cleaned output. Your code never left your browser.

FAQ

HTML questions, answered.

What about IE conditional comments?

+

Conditional comments use the same <!-- --> syntax, so they are removed along with regular comments. If you still target IE, run the tool earlier in your build and add them back.

Will it touch <script> or <style> contents?

+

No. Inline JavaScript and CSS are preserved as-is. Run the JavaScript or CSS pages to clean those bodies separately.

Does it work on JSX-flavored HTML?

+

JSX uses {/* */} comments inside expressions, which is JavaScript syntax. Use the JavaScript or TypeScript pages for .jsx / .tsx files.

Other languages

Working in something else?

Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.

Try it on your HTML code now.

Free forever. No signup. No upload. Runs entirely in your browser.

Open uncommenter