Remove comments from JavaScript

Paste JavaScript that has // and /* */ comments in it. This strips them out and hands back the same code with nothing else touched.

JavaScript
With comments
Loading editor…
Cleaned
Cleaned JavaScript will appear here.

Why strip comments from JavaScript

Most JS files pick up cruft over time. A TODO nobody resolved, a block that's commented out instead of deleted, a note that made sense to whoever wrote it six months ago and to nobody since. Stripping comments is a quick way to see what the code actually does, without the running commentary on top of it.

It's also the first step before minifying a script or pasting a snippet into a bug report where the internal notes aren't relevant to anyone reading it.

What counts as a comment in JavaScript

JavaScript has two comment styles: a // line comment that runs to the end of the line, and a /* */ block comment that can span several lines. Both get removed. Anything sitting inside a string, a template literal, or a regular expression is left alone, since it isn't a comment even if it happens to contain //.

Frequently asked questions

Does this touch JSX or template literals?

No. Only real // line comments and /* */ block comments get removed. Anything inside a string, template literal, or regex stays exactly as written.

Will it break my code?

It shouldn't. The parser knows the difference between a comment and a // inside a string like "https://example.com", so URLs and similar patterns are left alone.

Can I paste a whole file, not just a function?

Yes, up to 20,000 characters per request on the free tier. Upgrade to Pro for unlimited comment removal.