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! π