Skip to content

Remove HTML Comments

Strip all comments from your HTML code in one click. Keep license notes or conditional comments if you need them. Fast, free and no signup.

  • 100% free
  • No Signup
  • Works in your browser

Your HTML

0 characters

Clean HTML

Your cleaned HTML will appear here.

ADVERTISEMENT
Demo Ad 728 x 90 320 x 100

Remove HTML comments in 3 simple steps

  1. 1

    Paste your HTML

    Add a full page, a template or a small snippet of code.

  2. 2

    Choose your options

    Keep conditional or license comments if you need them.

  3. 3

    Copy the clean code

    Copy the result or download it as an .html file.

HTML CLEANUP GUIDE

Remove HTML Comments – Free HTML Comment Remover to Strip Comments from Your Code

Want to remove HTML comments from a page, a template or a code snippet without writing a regular expression? Our free HTML comment remover strips every <!-- comment --> from your code in one click. You can remove comments from HTML online, keep the ones that matter, such as license notices and Outlook or Internet Explorer conditional comments, and leave script and style blocks untouched. There is no signup, no software to install and no limit on use. Paste your HTML, press the button and copy the clean code. It is a quick way to strip HTML comments before publishing a website, to clean a template you downloaded, to prepare an email template, to shrink the size of a page, or to remove notes, TODOs and old code that developers left behind in the source. Everything runs in your browser, so your code stays on your device while you work.

Searches such as remove HTML comments, strip comments from HTML, delete HTML comments online and HTML comment remover all point to the same need: a clean page source without leftover notes. This tool is built for web developers, bloggers, email designers and site owners who want to clean a page before it goes live. It protects the parts of your code that must not change, shows a summary of what was removed, and runs on Windows, Mac, Linux, Android and iPhone because everything happens in your browser.

Strip All HTML Comments

Delete single-line and multi-line comments in one pass, including comments that stretch over many lines and comments sitting in the middle of a line. Every comment from the opening marker to the closing marker is removed, and the rest of your markup is left exactly as it was.

Keep What Must Stay

Protect conditional comments used by old Internet Explorer and by Outlook email templates, and keep license or copyright comments when your project requires them. Selective removal means you clean the noise without breaking layouts or legal notices.

No Empty Lines Left Behind

When a comment sits alone on its own line, removing it can leave a blank gap. The cleanup option deletes those lines automatically, so your HTML stays neat and readable instead of full of empty space.

How to Remove Comments from HTML Online (Step by Step)

Removing comments by hand is slow, and searching with a regular expression is easy to get wrong. With this online HTML comment remover you can delete comments from HTML code in under a minute. Follow these simple steps.

  1. Paste your HTML: Copy a full page, a template file or just a section of markup and paste it into the input box.
  2. Choose your options: Keep conditional comments on for email and legacy code, switch on keep license comments if you need copyright notes, and keep skip script, style and textarea on to protect those blocks.
  3. Click Remove comments: The cleaned HTML appears in the result box. The tool also updates automatically as you type or change an option.
  4. Check the summary: The result line shows how many comments were found, removed and kept, and how much smaller your code became.
  5. Copy or download: Use Copy result to paste the code back into your editor, or Download .html to save it as a file.

The tool works on whole pages and small fragments alike, so you can use it on a single div or on a 5,000-line template.

What Is an HTML Comment? A Quick Refresher

An HTML comment is a piece of text that the browser reads but never shows on the page. It starts with <!-- and ends with -->, and everything between those markers is ignored when the page is displayed. Developers use comments to explain sections of a layout, leave reminders such as TODO notes, mark where a component begins and ends, or temporarily switch off a block of markup while testing.

The important detail is that comments are hidden from the visitor's screen but not from the visitor's browser. They are part of the HTML file that is downloaded, so anyone who opens the page source can read them. That is the main reason people look for a way to remove comments from HTML before a site goes live.

HTML comment syntax at a glance
Type Example What it does
Single-line comment <!-- Main menu --> Short note on one line
Multi-line comment <!-- line one
line two -->
Longer note or a disabled block of markup
Conditional comment <!--[if IE 8]> ... <![endif]--> Old Internet Explorer rules, still common in email templates
License comment <!-- Copyright 2026 Example Ltd --> Legal or attribution notice

Why Remove HTML Comments from Your Website Code?

Comments are useful while you build a site, but they rarely help once the site is live. Here are the most common reasons to strip HTML comments before publishing.

  • Smaller HTML files: Every comment adds bytes to the page. On large templates with many commented sections, removing them reduces the size of the HTML that every visitor downloads.
  • Cleaner page source: A source file without leftover notes is easier to read, debug and review.
  • Protect internal information: Comments can reveal file paths, internal names, developer notes, old URLs, staging details or hints about how a system works. Removing them reduces what a curious visitor can learn from view-source.
  • Remove old and dead code: Blocks of markup that were commented out months ago only add clutter and confusion.
  • Professional delivery: Clients and customers who open the source see tidy, production-ready code.
  • Prepare for minification: Removing comments is the first step of most HTML minification workflows.

Keep in mind that comments do not directly decide your search ranking, and search engines ignore them when they read your page. The real benefits are a lighter file, a cleaner source and fewer accidental information leaks.

Conditional Comments: When You Should Not Remove Them

Not every comment is just a note. Conditional comments look like normal comments, but some software reads them as instructions. Old versions of Internet Explorer used them to load special styles, and Microsoft Outlook still uses them in HTML email to apply layout fixes. If you delete these by mistake, an email that looked perfect in Gmail can suddenly break in Outlook.

That is why the option to keep conditional comments is switched on by default. When it is on, anything that starts with <!--[if and its closing <![endif]--> part is left in place, and only ordinary comments are deleted. Turn it off only when you are sure your project does not need support for those older rendering engines.

  • HTML email templates: Keep conditional comments, because Outlook relies on them.
  • Legacy websites: Keep them if the site must still work in very old browsers.
  • Modern websites: You can usually remove them, since current browsers ignore them.

Script, Style and Textarea Blocks: Why They Are Protected

Inside script, style and textarea elements the browser does not read HTML at all. It treats the content as raw text, so a sequence that looks like a comment there may actually be part of JavaScript, CSS or user text. Removing it could change how your code behaves. For this reason the tool skips these blocks by default and only cleans the normal HTML around them.

If you also want to delete comments inside JavaScript or CSS, those use different syntax, such as double slashes and slash-star comments, and need a JavaScript or CSS minifier. This tool focuses on real HTML comments, which is exactly what most people mean when they search for how to remove comments from HTML.

Remove HTML Comments: Online Tool vs Regex vs Code Editor

There are several ways to delete HTML comments. The right one depends on how often you do it and how much risk you are willing to take with your code. The table below compares the most common methods.

Ways to remove comments from HTML
Method Setup Strengths Risks
Online HTML comment remover None, paste and click Keeps conditional and license comments, skips script and style, shows a summary Needs a browser and copy and paste
Find and replace with regex in a code editor Open the file, write a pattern Works across many files A careless pattern can remove too much, or break conditional comments and script content
Build tool or HTML minifier Install and configure a package Automatic on every build Takes time to set up, and output may be hard to read
Manual deletion None Full control for a few comments Slow, and easy to miss comments in long files

For one-off cleanups of a template, snippet or downloaded page, an online comment remover is usually the quickest and safest choice. For a project that you rebuild every day, add comment removal to your build process as well.

Common Mistakes When Deleting Comments from HTML

Removing comments looks simple, but a few mistakes come up again and again. Knowing them helps you get a clean result without breaking your page.

  • Using a greedy pattern: A pattern that matches from the first comment start to the last comment end deletes everything in between, including real content. A correct pattern must stop at the first closing marker.
  • Deleting conditional comments: This silently breaks Outlook email layouts and legacy browser fixes.
  • Touching script and style content: Raw text blocks should not be edited as if they were HTML.
  • Forgetting unclosed comments: A comment that was opened but never closed hides everything after it in the browser. The tool warns you when it finds one so you can fix the source.
  • Removing legal notices: Some licenses require the copyright note to stay in the file, so use the keep license comments option when needed.
  • Not testing afterward: Always open the cleaned page or send a test email before publishing.

HTML Comments in Templates: Blade, PHP and WordPress

Many websites are built with template engines, and it helps to know which comments really reach the browser. A normal HTML comment written in a template is sent to the visitor, just like any other HTML. A comment written in the template language itself is different. For example, a Laravel Blade comment written with double curly braces and two dashes is removed on the server and never appears in the page source. A PHP comment inside a PHP block is also removed before the page is sent.

This tool removes HTML comments only. It leaves template syntax, PHP blocks and Blade comments alone, which is what you want when you clean a template file. If you paste the rendered HTML of a WordPress, Laravel or other CMS page, it will strip the HTML comments that plugins, themes and builders add, such as builder markers and cache notes, while keeping the rest of the page intact.

Strip HTML Comments for Email Templates and Landing Pages

HTML email and landing pages often come from visual builders that add many markers and notes. Cleaning these before sending reduces file size, which matters because some email clients clip long messages, and it removes internal labels that recipients should never see in the source. Use the default settings for email, so Outlook conditional comments stay in place while normal comments are deleted. For a landing page that only targets modern browsers, you can switch off the conditional comment option and get the smallest result.

  • Newsletter templates: Remove builder notes and keep Outlook conditionals.
  • Landing pages: Remove all comments to shrink the page and hide internal notes.
  • Downloaded website themes: Delete the author's section markers and old commented-out code.
  • Code samples for documentation: Strip comments to show only the final markup.

Remove HTML Comments on Any Device, No Software Needed

Our HTML comment remover runs in your web browser, so you can clean code on Windows, Mac, Linux, Android and iPhone without installing an editor extension or a command line tool. Open the page, paste your HTML, choose your options and copy the result. There is no account to create, and because processing happens on your own device, your source code is not sent to our server. That makes it a convenient option when you are away from your main computer, working on a shared machine or just need a fast cleanup of a small snippet.

Tips for the Cleanest Results

  • Back up first: Keep a copy of the original file, especially if it contains notes you may want later.
  • Start with the defaults: They are safe for most websites and for email templates.
  • Keep license comments for third-party code: Libraries and themes sometimes require their notice to stay.
  • Read the summary: If the number of kept comments surprises you, check which options are on.
  • Test in a browser: Open the cleaned HTML and compare it with the original before going live.
  • Combine with other cleanup: After removing comments, you can also remove duplicate lines or extra spaces with our other text tools.

Options at a Glance

The tool has four options. The table shows what each one does and when to change it.

Settings of the HTML comment remover
OptionWhat it doesWhen to change it
Keep conditional commentsLeaves IE and Outlook if comments untouchedTurn it off only if you do not support old browsers or Outlook
Keep license commentsKeeps comments with copyright, license or a leading exclamation markTurn it on when your project must keep legal notices
Skip script, style and textareaDoes not touch code inside these blocksKeep it on so JavaScript, CSS and user text are never changed
Clean up empty linesDeletes lines that only held a commentTurn it off if you want to keep the original line numbers

Before and After: What Gets Removed and What Stays

The table shows how common types of comments are handled with the default settings.

How each type of comment is handled
Type of commentExampleDefault result
Normal comment<!-- Main menu -->Removed
Multi-line comment<!-- line one and line two -->Removed
Conditional comment<!--[if IE]> ... <![endif]-->Kept
License comment<!-- Copyright 2026 Example Ltd -->Removed unless Keep license comments is on
Text inside script or styleA string that looks like a commentLeft untouched

Who Uses an HTML Comment Remover?

  • Web developers: Clean templates and build output before deployment.
  • Bloggers and site owners: Remove notes and leftover code from themes and page builders.
  • Email designers: Strip comments from HTML email while keeping the Outlook rules that make layouts work.
  • Agencies and freelancers: Deliver tidy, production-ready code to clients.
  • SEO and performance specialists: Trim page weight and remove internal notes from the page source.
  • Students and learners: Clean example code copied from tutorials.

Troubleshooting: Why Is a Comment Still There?

  • Conditional comment: Comments that start with the if marker are kept on purpose. Turn off Keep conditional comments to remove them.
  • License comment: If Keep license comments is on, comments with copyright or license words stay.
  • Inside a script or style block: These blocks are skipped by default. JavaScript and CSS use different comment syntax.
  • Server-side comments: Blade, PHP and WordPress comments are removed on the server and are not part of the HTML. Paste the rendered page source to clean it.
  • Comment not closed: A comment without a closing marker is not a complete comment, so check your code for a missing end.

Is It Safe to Use an Online HTML Comment Remover?

Your code is cleaned inside your browser. It is not uploaded to a server and not stored, and it disappears when you close or refresh the page. As a general habit, keep a copy of your original file, check the result in a browser before you publish it, and avoid pasting passwords or API keys into any online tool.

More Free Text Tools You May Need

Cleaning code is often more than one step. These related free tools can help:

Free Online HTML Comment Remover: Fast, Safe and Private

Our free tool was built to make HTML cleanup simple for developers, designers, bloggers and site owners alike. If you want a way to remove HTML comments, strip comments from HTML code and clean up page source without breaking conditional comments, this page gives you that in one click. Paste your code, choose what to keep and copy a clean result in seconds.

Ready to try it? Scroll back up, paste your HTML and remove the comments now. If you also need to sort lines, count words or convert text case, explore the other free text tools on our site.

ADVERTISEMENT
Demo Ad 300 x 250 300 x 250
COMMON QUESTIONS

Remove HTML Comments FAQ

Quick answers about stripping comments from HTML, keeping conditional comments and using the tool safely.

How do I remove HTML comments online for free?

Paste your HTML into the input box, leave the default options on and click Remove comments. The cleaned code appears in the result box, and you can copy it or download it as an HTML file. It is free, needs no signup and works on phones and computers.

Will removing comments change how my page looks?

No. Browsers never display comments, so deleting them does not change the visible page. The only exception is a comment that was opened but never closed, which can hide content in the browser. The tool warns you when it finds an unclosed comment so you can fix it.

Does the tool remove Outlook and Internet Explorer conditional comments?

Not by default. The Keep conditional comments option is switched on, so comments that start with the if condition and end with the endif marker stay in your code. This protects HTML email layouts in Outlook. Switch the option off if you want every comment removed.

Are comments inside script and style tags removed?

By default, no. Script, style and textarea blocks are skipped because the browser treats their content as raw text, not HTML. If you need to remove JavaScript or CSS comments, use a JavaScript or CSS minifier, since those languages use their own comment syntax.

Do HTML comments affect SEO or page speed?

Search engines ignore comments, so they do not directly help or hurt your ranking. Comments do add bytes to the HTML file, so on pages with many of them, removing comments can make the download slightly lighter. It also keeps internal notes out of your public page source.

Can I use it on Blade, PHP or WordPress templates?

Yes. The tool removes only HTML comments and leaves template syntax and PHP code alone. Blade and PHP comments are already removed on the server and never reach the browser, so they are not touched here. You can also paste the rendered HTML of a WordPress or CMS page to strip the comments added by themes and plugins.

Is my code safe, and is there a size limit?

The cleaning happens inside your browser, so your code is not uploaded to our server or stored by us. There is no fixed size limit, but very large files depend on your device's memory, so split extremely big files into parts. As a general habit with any online tool, avoid pasting passwords or secret keys.

ADVERTISEMENT
Demo Ad 728 x 90 320 x 100