Formatter & Minifier

Remove Comments


Strip single-line and block comments from source code in many languages — string-aware, private, and running entirely in your browser.

💡 About this tool

  • Removes single-line and block comments from a dozen languages — pick your language from the dropdown.
  • String-aware: a //, #, or /* */ that lives inside a string or a URL is left untouched.
  • Python triple-quoted docstrings and other string literals are preserved — only real comments go.
  • Tick Remove blank lines left behind to also collapse the empty lines that stripping comments leaves.
  • Runs entirely in your browser — nothing is uploaded, so it's safe for private code.

The Remove Comments tool is a free, 100% client-side utility that strips comments out of source code.

Paste your code, choose the language from the dropdown, and it removes single-line and block comments in one pass.

What sets it apart is that it is string-aware. A comment token that lives inside a string literal, a URL, or a docstring is left completely untouched.

Everything runs locally in your browser. Your code is never uploaded, stored, or seen by any server, so it is safe for private and proprietary work.

What does removing comments do?

Removing comments deletes the human notes from your code while leaving the executable logic exactly as it was.

Comments are ignored by compilers and interpreters, so stripping them does not change how your program runs.

It simply produces a leaner, cleaner version of the same file.

Why remove comments from code?

There are plenty of everyday reasons to strip comments before you share or ship a file.

  • Ship cleaner code — hand over a tidy file without scaffolding notes, reminders, or commented-out experiments.
  • Reduce size before minifying — remove comment bytes as a first pass, then run a minifier for the smallest possible output.
  • Strip TODOs and FIXMEs — clear out internal // TODO and // FIXME notes that should not travel to production.
  • Remove secrets left in comments — delete stray keys, tokens, or URLs that were pasted into a comment during debugging.
  • Cleaner snippets for docs — paste a focused, comment-free example into documentation, a blog post, or a support ticket.

How to remove comments

The workflow takes only a few seconds.

  1. Paste or type your code into the Source code box.
  2. Pick your language from the Language dropdown so the right comment rules apply.
  3. Optionally tick Remove blank lines left behind to collapse the empty lines that comments leave behind.
  4. Read the stripped result in the output box.
  5. Use Copy or Download to save the cleaned code.

Why string-aware removal matters

Most quick comment removers are naive regular expressions, and that is where they go wrong.

A regex that deletes everything after // will happily wreck a URL like "http://x.com", turning a valid string into a broken one.

This tool actually tracks whether it is inside a string, so those tokens are safe.

A hash inside a quoted value such as '#tag' stays put, because # is only a comment when it is real code, not text.

A Python triple-quoted docstring like """usage: run --flag # not a comment""" is a string, so nothing inside it is removed.

An SQL literal such as '-- literal' keeps its dashes, even though -- starts a comment elsewhere in the same query.

The same protection covers block markers, so a /* */ sequence written inside a string is preserved rather than misread as the start of a comment.

Which languages are supported?

Choose any of these from the dropdown, and the matching comment syntax is applied automatically.

  • JavaScript// line comments and /* */ block comments.
  • TypeScript — same // and /* */ rules as JavaScript.
  • PHP//, #, and /* */ comments.
  • Python# comments, with triple-quoted docstrings preserved as strings.
  • C / C++ / C# / Java / Go / Rust / Swift — the shared // and /* */ family.
  • CSS/* */ block comments.
  • SCSS / Sass / LESS — both // and /* */ comments.
  • HTML / XML<!-- --> comments.
  • SQL-- line comments and /* */ block comments.
  • Shell / Bash# comments with word-aware handling.
  • YAML# comments.
  • Ruby# comments and =begin/=end blocks, with strings preserved.

How does shell comment handling work?

Shell scripts have a subtle rule that trips up naive removers.

In Bash a # only starts a comment when it begins a word, so echo foo#bar prints foo#bar and the hash is not a comment at all.

This tool respects that, removing a # comment only when it truly starts one and leaving inline hashes like that intact.

Does it remove empty lines too?

Yes, if you want it to.

When you strip a full-line comment, an empty line is usually left where it used to be.

Tick the Remove blank lines left behind checkbox and those hollow lines are collapsed, giving you a tight, gap-free file.

Leave it unticked if you would rather keep the original line spacing.

Remove Comments features

  • Many languages from a single dropdown, each with the correct comment syntax.
  • String-aware parsing that never deletes a token inside a string, URL, or docstring.
  • Single-line and block comments handled together in one pass.
  • Optional blank-line collapsing for a clean, compact result.
  • Shell word-aware handling so inline hashes survive.
  • Copy and Download to grab the cleaned output instantly.
  • 100% private — nothing is uploaded, so it is safe for confidential code.

What to do next

Removing comments pairs naturally with formatting and minifying.

For PHP, tidy the stripped file with the PHP Beautifier before you commit it.

For front-end scripts, shrink the comment-free result further with the JavaScript Minifier for production.

Cleaning up a page? Run the markup through the HTML Minifier after stripping its comments.

And for stylesheets, feed the stripped CSS into the CSS Minifier to squeeze out the last few bytes.

Frequently Asked Questions

Which languages are supported?

You can remove comments from JavaScript, TypeScript, PHP, Python, the C family (C, C++, C#, Java, Go, Rust, and Swift), CSS, SCSS, Sass, LESS, HTML, XML, SQL, Shell, Bash, YAML, and Ruby. Pick the matching entry from the dropdown so the correct comment syntax is applied.

Will it remove comments inside strings or URLs?

No. The tool is string-aware, so a comment token that appears inside a string literal or a URL is never removed. A value like "http://x.com" or '#tag' is left exactly as written, unlike naive regex removers that would corrupt it.

Does it delete Python docstrings?

No. A Python triple-quoted docstring is a string, not a comment, so the tool leaves it fully intact. Only real # comments are stripped from your Python code.

Can it also remove the blank lines left behind?

Yes. Tick the "Remove blank lines left behind" checkbox and the empty lines left after full-line comments are stripped will be collapsed, giving you a compact, gap-free file. Leave it unticked to keep the original spacing.

Is my code uploaded anywhere?

No. Everything runs locally in your browser with client-side JavaScript. Your code is never uploaded, stored, or seen by any server, which makes the tool safe for private and proprietary source.

Does removing comments change how my code runs?

No. Comments are ignored by compilers and interpreters, so removing them does not affect how your program behaves. You get the same working code with the notes taken out.