Remove code comments with one click, keeping your code clean!
If you like this project, please give it a ⭐️!
This powerful Python script intelligently identifies and removes comments from various programming language files, making your code cleaner and more concise. It supports popular languages like Python, JavaScript, Java, C/C++, C#, PHP, and more! And it win a 9.67/10.0 Pylint mark.
- 🎯 Multi-language Support – Automatically recognizes multiple programming languages
- 📝 Smart Comment Removal – Accurately handles single-line and multi-line comments
- 📂 Batch Processing – Supports single files or entire directories
- 🔁 Recursive Operation – Optional handling of nested directory structures
- 🧩 Merged Output – Combines multiple files into a single output file
- ✨ Special Handling – Adds standardized comment headers for Java files
pip install -r requirements.txt
python main.py path/to/file.py -o output_directory
python main.py path/to/directory -o output_directory
python main.py path/to/directory -o output_directory -r
python main.py path/to/directory -o output_directory -c
python main.py path/to/directory -o output_directory -r -c
- Smart File Recognition: Automatically determines file type based on extension
- Preserves Original Structure: Output files are appended with "_no_comments"
- Special Comment Handling: Java files automatically receive standardized path comment headers
- Custom Extensions: Easily add support for new languages
Original file structure:
src/
├── main.py
└── utils/
├── helper.js
└── config.php
Processed structure:
output/
├── main_no_comments.py
└── utils/
├── helper.js
├── config.php
├── helper_no_comments.txt
└── config_no_comments.txt
To support additional languages, edit the following in the script:
COMMENT_PATTERNS
– Add comment patterns for new languagesFILE_EXTENSIONS
– Map file extensions to languages
- Enhance special comment header functionality (support more path patterns)
- Add support for more languages
- Implement comment statistics feature
- Develop a GUI version
PRs and Issues are welcome! Let’s build a more powerful code-cleaning tool together!
AGPL 3.0
Experience the refreshing world of comment-free code today! 🎉