A CLI tool to remove comments from source code files
npm install 00akshatsinha00decommentbash
npx 00akshatsinha00decomment -w .
`
Or install it globally if you prefer:
`bash
npm install -g 00akshatsinha00decomment
`
Quick Start
Remove comments from all files in the current directory:
`bash
npx 00akshatsinha00decomment -w .
`
Remove comments from specific JavaScript files:
`bash
npx 00akshatsinha00decomment -w *.js
`
Preview changes without modifying files:
`bash
npx 00akshatsinha00decomment myfile.js
`
Usage
`
00akshatsinha00decomment [options]
Arguments:
glob glob pattern(s) of files to decomment
Options:
-V, --version output the version number
-w, --write overwrite files in-place
-o, --out write cleaned files to specified directory
-h, --help display help for command
`
Options Explained
$3
Modifies your files directly by removing comments and saving the changes back to the original files.
Example:
`bash
npx 00akshatsinha00decomment -w src/*/.js
`
Warning: This permanently modifies your files. Make sure you have backups or version control in place.
$3
Creates cleaned versions of your files in a specified output directory while keeping your original files unchanged.
Example:
`bash
npx 00akshatsinha00decomment -o cleaned-code src/*/.js
`
This creates a cleaned-code directory with comment-free versions of your files.
$3
When you don't specify -w or -o, the tool displays the cleaned content in your terminal without modifying any files.
Example:
`bash
npx 00akshatsinha00decomment myfile.js
`
Supported File Types
This tool works with all major programming languages and file types:
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- CSS (.css, .scss, .sass, .less)
- HTML (.html, .htm)
- JSON (.json)
- And many more
The tool automatically detects the file type and uses the appropriate comment removal strategy.
Examples
$3
`bash
npx 00akshatsinha00decomment -w .
`
$3
`bash
Only JavaScript files
npx 00akshatsinha00decomment -w "*/.js"
Only CSS files
npx 00akshatsinha00decomment -w "*/.css"
Multiple file types
npx 00akshatsinha00decomment -w "*/.{js,css,html}"
`
$3
`bash
Clean files in src directory
npx 00akshatsinha00decomment -w "src/*/"
Clean files in multiple directories
npx 00akshatsinha00decomment -w "src//" "lib//"
`
$3
`bash
Create cleaned versions in 'dist' folder
npx 00akshatsinha00decomment -o dist "src/*/.js"
`
$3
`bash
See what changes would be made without modifying files
npx 00akshatsinha00decomment "src/myfile.js"
`
What Gets Removed
The tool removes various types of comments while preserving your code's functionality:
- Single-line comments: // This is a comment
- Multi-line comments: / This is a comment /
- JSDoc comments: /* Documentation comment /
- CSS comments: / CSS comment /
- HTML comments:
What Stays Intact
Your code functionality remains completely unchanged:
- All executable code
- String literals (even if they contain comment-like text)
- Regular expressions
- Code structure and formatting
- Variable names and values
Error Handling
The tool handles errors gracefully and provides helpful feedback:
- File permission errors: Clear messages about access issues
- Invalid patterns: Helpful suggestions for correct glob patterns
- No matching files: Informative message when no files are found
- Processing errors: Continues with other files if one file fails
Glob Patterns
You can use powerful glob patterns to specify which files to process:
| Pattern | Description | Example |
|---------|-------------|---------|
| | Match any file in current directory | .js |
| | Match files in any subdirectory | /*.js |
| ? | Match single character | file?.js |
| {a,b} | Match either a or b | *.{js,css} |
| [abc] | Match any character in brackets | file[123].js |
Safety Features
- Backup recommendation: Always use version control or create backups before using -w
- Preview mode: Test patterns without the -w flag first
- Error recovery: Processing continues even if individual files fail
- Clear feedback: Detailed success and error messages
- Exit codes: Proper exit codes for scripting (0 for success, 1 for errors)
Common Use Cases
$3
`bash
npx 00akshatsinha00decomment -o review-ready "src/*/.js"
`
$3
`bash
npx 00akshatsinha00decomment -w "dist/*/.js"
`
$3
`bash
npx 00akshatsinha00decomment -w "legacy/*/.{js,css,html}"
`
$3
`bash
npx 00akshatsinha00decomment -o examples "src/components/*.js"
`
Troubleshooting
$3
If you see "No files found matching the specified patterns":
- Check your glob pattern syntax
- Ensure the files exist in the specified locations
- Try using quotes around your patterns: "*/.js"
$3
If you encounter permission errors:
- Ensure you have write access to the target files
- Check if files are currently open in other applications
- Run with appropriate permissions if needed
$3
If the output isn't what you expected:
- Test with preview mode first (without -w or -o)
- Check that your files are in a supported format
- Verify your glob patterns match the intended files
$3
If your glob pattern isn't matching files:
- Use quotes around patterns with special characters
- Test patterns with simple examples first
- Remember that **` is needed for subdirectories