| Crates.io | comments-cleaner |
| lib.rs | comments-cleaner |
| version | 0.1.3 |
| created_at | 2025-11-06 10:55:37.609939+00 |
| updated_at | 2025-11-06 10:55:37.609939+00 |
| description | A command-line tool for cleaning code comments, supporting multiple programming languages |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1919434 |
| size | 61,179 |
A powerful command-line tool for automatically removing comments from code in multiple programming languages.
| Language | File Extensions | Comment Types |
|---|---|---|
| C | .c, .h |
// and /* */ |
| C++ | .cpp, .cc, .cxx, .hpp, .hxx |
// and /* */ |
| Java | .java |
// and /* */ |
| JavaScript | .js, .jsx |
// and /* */ |
| TypeScript | .ts, .tsx |
// and /* */ |
| Python | .py, .pyw |
# and """...""" / '''...''' |
| HTML | .html, .htm |
<!-- --> |
| CSS | .css |
/* */ |
| PHP | .php |
//, # and /* */ |
| Rust | .rs |
// and /* */ |
| Basic | .vb, .bas, .vba, .vbs |
' and REM |
You can download the latest pre-built executable from the Releases page.
git clone https://github.com/cyber-tao/comments-cleaner.git
cd comments-cleaner
cargo build --release
The compiled executable will be located at target/release/cclean.exe (Windows) or target/release/cclean (Linux/macOS)
cargo install --path .
cclean <file or directory path> [options]
cclean src/main.cpp
Output: src/main_cleaned.cpp
cclean src/main.cpp -i
cclean src/main.cpp -o output/main.cpp
cclean src/main.cpp -i -b
Output: Modify original file, create src/main.cpp.bak
cclean src/ -r -i
cclean src/ -r -o cleaned/
cclean src/ -r -e "cpp,h,hpp"
cclean script.txt -l cpp -o script_cleaned.txt
cclean src/ -r --dry-run
| Option | Short | Description |
|---|---|---|
--output <PATH> |
-o |
Specify output file or directory path |
--recursive |
-r |
Recursively process all files in directory |
--in-place |
-i |
Modify original file directly |
--backup |
-b |
Create backup file (.bak) |
--lang <LANGUAGE> |
-l |
Manually specify programming language |
--dry-run |
Dry run, do not actually modify files | |
--extensions <EXT> |
-e |
Specify file extensions to process (comma-separated) |
--help |
-h |
Show help information |
--version |
-V |
Show version information |
When using -l or --lang option, you can use the following language identifiers:
c: C languagecpp or c++: C++java: Javajs or javascript: JavaScriptts or typescript: TypeScriptpython or py: Pythonhtml: HTMLcss: CSSphp: PHPrust or rs: Rustbasic, vb, vba, or vbs: Basic-b option to create backups--dry-run firstcclean ./project -r -o ./project_cleaned
cclean ./src -r -i -b
This will:
cclean ./src -r -e "js,jsx" -o ./dist
// single-line comments and /* */ multi-line comments# comments and triple-quoted strings """...""" / '''...''' (including docstrings, replaced with empty string "")<!-- --> comments, also process comments in embedded <script> and <style> tags/* */ comments// single-line comments, # comments, and /* */ multi-line comments' single-line comments and REM keyword commentsAfter removing comments, the tool will automatically:
The tool uses state machine parsing to correctly handle:
cargo test
cargo run -- <arguments>
Example:
cargo run -- test.cpp
MIT License
Issues and Pull Requests are welcome!