About Remove Code Comments
This tool strips comments from source code. Choose the comment style that matches your language: C-style for JavaScript, Java, C, C++ and C#, PHP style, CSS, hash comments for Python, shell, YAML and .htaccess, HTML comments, or SQL.
The scanner skips over quoted strings, so a URL such as "https://example.com" or a hash character inside a string is not mistaken for a comment. Trailing comments at the end of a code line are removed, and the extra blank lines they leave are collapsed.
How to use Remove Code Comments
- Choose the comment style that matches your code.
- Paste the code into the input box and click Run Tool.
- Copy the clean code from the output box.
Example
Input
// connect to the API
const url = "https://example.com/api"; // keep this string
/* old code
const x = 1;
*/
function run() {
return fetch(url); // send request
}Output
const url = "https://example.com/api";
function run() {
return fetch(url);
}Common uses
- Preparing a snippet for sharing without internal notes.
- Reducing a file before you minify or compare it.
- Checking what a script does without the commentary.
Privacy and safety
This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.
Frequently asked questions
Why do I have to choose a language?
Comment markers differ. In CSS a line beginning with # is a selector, while in Python it is a comment. Picking the style prevents valid code from being deleted.
Does it remove documentation blocks?
Yes. Block comments such as /** ... */ are removed along with other comments, including JSDoc and PHPDoc.
Can it misread a regular expression?
Regular expression literals that contain quotes or // can confuse the scanner. Review the output of code that uses complex regex.