A Node.js tool for cleaning comments from your files while preserving code structure. Supports HTML, EJS, CSS, JavaScript, TypeScript, and more.
- Removes comments from multiple file types:
- HTML/EJS comments (
<!-- -->,<%-- --%>) - CSS comments (
/* */) - JavaScript/TypeScript comments (
//and/* */)
- HTML/EJS comments (
- Preserves code structure and formatting
- Handles nested directories
- Maintains original file extensions
- Provides detailed processing statistics
- Zero external dependencies
# Clone the repository
git clone https://github.com/immapolar/Kleen-Web-Assets.gitnode kleen.jsproject/
├── src/ # Input
│ ├── styles.css
│ ├── main.js
│ └── index.html
└── dist/ # Output
├── styles.css
├── main.js
└── index.html
Note
Always keep a backup of your source files before cleaning. This tool performs irreversible changes to your files.
Caution
The tool removes all types of comments, including:
- Documentation comments
- License information
- Important development notes Make sure to save them separately before processing.
- HTML (.html)
- EJS (.ejs)
- CSS (.css)
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
// This is a single line comment
function hello() {
/* This is a
multi-line comment */
console.log('Hello World'); // End of line comment
}function hello() {
console.log('Hello World');
}const cleaner = new CommentsCleaner();
cleaner.processDirectory('./src', './dist', [
'.html',
'.vue',
'.php'
]);const cleaner = new CommentsCleaner();
cleaner.processFile(
'./src/input.js',
'./dist/output.js'
);This project is MIT licensed.
The tool provides detailed error logging:
- File access errors
- Processing failures
- Invalid directory structures
- Does not preserve license headers
- Removes all types of comments indiscriminately
- May require adjustment for specific framework syntaxes
Made with ❤️ by Polaris