
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
remove-comments-cli
Advanced tools
A fast and flexible CLI tool to remove comments from JavaScript/TypeScript files while preserving important ones
A fast and flexible CLI tool to remove comments from JavaScript/TypeScript files while preserving important ones.
npm install remove-comments-cli --save-dev
Remove all comments from a file:
npx remove-comments input.ts > output.ts
Process multiple files using glob patterns:
npx remove-comments "src/**/*.{js,ts,jsx,tsx}" --outDir dist
By default, comments starting with ! are preserved:
// This comment will be removed
//! This important comment will be preserved
/* This block comment will be removed */
/*! This important block comment will be preserved */
You can specify custom markers:
# Preserve comments starting with # or *
npx remove-comments input.ts -k "#*" > output.ts
npx remove-comments --help
Options:
-k, --keep-markers <chars> Characters that mark comments to preserve (default: "!")
-o, --outDir <dir> Output directory for processed files
-v, --verbose Print detailed processing information
-h, --help Display help information
Process TypeScript files and preserve comments starting with ! or #:
npx remove-comments "src/**/*.ts" -k "!#" --outDir dist
Process JSX/TSX files and preserve comments starting with *:
npx remove-comments "src/**/*.{jsx,tsx}" -k "*" --outDir dist
Process a single file and output to stdout:
npx remove-comments input.js > output.js
The tool is optimized for performance and memory efficiency:
| Node.js Version | Support Status |
|---|---|
| 20.x | ✅ Full |
| 18.x (LTS) | ✅ Full |
| 16.x | ❌ Not supported |
Tested on:
"Error: ENOENT: no such file or directory"
"SyntaxError: Unexpected token"
--verbose for more details"Error: Cannot find module"
npm install remove-comments-cli againRun with debug logging enabled:
DEBUG=remove-comments* npx remove-comments input.ts
We welcome contributions! Please see our Contributing Guide for details.
MIT
FAQs
A fast and flexible CLI tool to remove comments from JavaScript/TypeScript files while preserving important ones
We found that remove-comments-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.