OK
Removes inline styles
Inline styles
Deletes classes and IDs
Classes & IDs
Deletes empty HTML tags
Empty tags
remove tags with one space
Tags with 1 space
remove successive spaces
Successive spaces
delete comments
Comments
remove tag attributes
Tag attributes
html to plain text
To plain text
Smart non-breaking spaces
Smart  s
ai watermarks remove
AI Watermarks

delete commentsRemove HTML Comments

HTML comments are useful during development, but in production they add noise and can leak implementation details. This tool removes comment blocks (<!-- ... -->) across your document, leaving only the content that actually renders. 🧹

🚀After stripping comments, you may also remove excess tag attributes or delete empty tags to further reduce page weight.

No comment Sin comentarios Nessun commento Kommentár nélkül

What gets removed?

  • HTML comments in the form <!-- any content -->
  • Multi-line comment blocks created during development
  • Notes, TODOs, and disabled markup left in the source
  • Framework-generated comments that don't affect rendering

Why remove comments?

  • Cleaner source: easier to read and maintain.
  • Smaller payload: fewer bytes sent over the network.
  • Security: avoids leaking internal notes or hints.
  • Better exports: comments don't pollute DOCX or text conversions.
Good practice: Keep comments in source files during development, but strip them from the final output that users and crawlers see.💬

Example: Before and After

Before (with comments):

<!-- Cleaned by Pretty HTML -->
<div class="card">
  <p>Content</p>
</div>

After (cleaned):

<div class="card">
  <p>Content</p>
</div>

How to use this page

  1. Paste or drop your HTML into the editor.
  2. Check the Comments button.
  3. Click Pretty to remove comment nodes.
  4. Download the cleaned HTML or DOCX if needed.

Common places comments appear

During development

  • Temporarily disabled markup
  • Notes explaining layout hacks
  • Debug reminders and TODOs

Generated content

  • CMS or page-builder markers
  • Framework hydration hints
  • Export artifacts from editors

Impact on performance and SEO

Comments do not affect how browsers render a page, and search engines generally ignore them. However, they still increase file size and can reveal information you'd rather keep private. Removing comments won't change semantics or rankings, but it contributes to a cleaner, faster, more professional output, especially when combined with other cleanup options. 📉

Aspect With comments Without comments Result
Source readability Noisy, mixed signals Focused on content Easier maintenance
Page size Larger Smaller Faster transfers
Security Possible info leaks No internal notes Safer output
Exports Comments included Clean content Better conversions

Removing comments with JavaScript

To remove comments programmatically, traverse the DOM and delete nodes with nodeType === Node.COMMENT_NODE. This approach is robust and avoids the pitfalls of regular-expression-based stripping. ⚙️

function removeHtmlComments(html) {
  var parser = new DOMParser();
  var doc = parser.parseFromString(html, 'text/html');
  var walker = doc.createTreeWalker(
    doc.body,
    NodeFilter.SHOW_COMMENT,
    null,
    false
  );
  var toRemove = [];
  for (var n = walker.nextNode(); n; n = walker.nextNode()) {
    toRemove.push(n);
  }
  toRemove.forEach(function (c) {
    c.parentNode.removeChild(c);
  });
  return doc.body.innerHTML; 
}

Optional: combine with other cleaning options

Removing comments often reveals empty elements or unused attributes.
Running a follow-up cleanup step keeps the final markup tidy and consistent. ✅

Workflow: Remove comments → strip unused attributes → remove empty tags → normalize spacing. This sequence produces compact, production-ready HTML.

FAQ

Will this remove conditional comments?

Modern browsers no longer rely on legacy conditional comments. If you still target very old environments, review the output before deploying.

<!--[if lte IE 8]>
     <link href="IE8fonts.css" rel="stylesheet" type="text/css">
<![endif]-->

Does this help SEO?

Indirectly with faster loading time id does. While comments aren't indexed, cleaner markup and smaller pages contribute to better performance and maintainability.

Prettify

Can comments affect layout?

Not directly, but they can confuse editors and tools that process the DOM. Removing them simplifies downstream processing.

Is it safe to remove all comments?

For production output, yes. Keep commented source versions in your repository if you need explanations later.

Back to top