How to remove comments from code
- Paste your code into the left panel, or click Sample to try it.
- Leave the language on Auto-detect, or choose it yourself for the most accurate result.
- Click Remove comments and copy the clean code from the right panel.
Lines that held only a comment are removed completely, and trailing comments are cut from the end of a line. Blank lines you already had are kept, so the layout of your code doesn't change.
What gets removed
- Python:
# comments, and optionally docstrings - JavaScript / TypeScript:
// lineand/* block */comments, including JSDoc - Java:
//,/* */and Javadoc comments - C / C++:
//and/* */comments —#includeand other preprocessor lines are kept
When to remove comments
Stripping comments is handy before sharing a snippet, minimising a script, counting real lines of code, or cleaning up AI-generated code that explains every line. For production code, consider keeping comments that explain why — the Code Humanizer can remove only the comments that repeat the code.
Related guides
Frequently asked questions
Will it remove # or // inside strings and URLs?
No. The tool reads your code the way a parser does, so text inside string literals, template literals and f-strings is never treated as a comment. A URL like "https://example.com/#top" stays exactly as it is.
Which languages are supported?
Python, JavaScript, TypeScript, Java, C and C++. Leave the language on Auto-detect or pick it yourself.
Does it keep eslint-disable, noqa and license comments?
Yes, by default. Comments that tools rely on — shebangs, # noqa, # type:, // eslint-disable, // @ts-ignore, /*! license */ blocks and similar — are kept. Untick "Keep tool directives" to remove them too.
Can it remove Python docstrings?
Yes. Tick "Remove Python docstrings". If a function's only statement is its docstring, the tool replaces it with pass so the code still runs.
Do I need an account?
No — you can use the free tools 5 times without one. After that, sign up or log in (it is free) for unlimited use of every tool.
Is my code stored?
No. Your code is processed in memory to produce the result and is never saved. See our Privacy Policy.