npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

comment-strip-cli

v1.0.0

Published

A powerful CLI tool to strip comments from source code files while preserving strings and important metadata

Downloads

9

Readme

Comment Strip CLI 🛠️

🚫 Tired of noisy, outdated, or AI-generated comments cluttering your code?
🔧 comment-strip-cli removes all the fluff in seconds — perfect for production-ready commits, open source cleanup, or polishing AI-assisted code.

🚀 Features

  • Multi-language support: JavaScript/TypeScript, C/C++, Python, Solidity, Rust, Go, Java, and many more
  • Smart parsing: Preserves comments inside strings and handles edge cases
  • Flexible filtering: Strip specific comment types (e.g., only // or only #)
  • Backup support: Create backups before modification
  • Dry-run mode: Preview changes before applying
  • Auto-formatting: Clean up code after comment removal
  • Recursive processing: Handle entire directories
  • Special file support: Dockerfile, Makefile, CMakeLists.txt

📦 Installation

Global Installation (Recommended)

npm install -g comment-strip-cli

Local Installation

npm install comment-strip-cli
npx comment-strip --help

🔧 Usage

Basic Usage

comment-strip --help
  • Strip all comments from a file:
comment-strip <FILE_NAME>
  • Strip all comments from a directory:
comment-strip <DIRECTORY_NAME>
  • Preview changes without modifying files:
comment-strip <FILE_NAME> --dry-run

Advanced Usage

  • Strip only single-line comments:
comment-strip <FILE_NAME> --type="//"
  • Strip only hash comments from Python files:
comment-strip script.py --type="#"
  • Create backup before processing:
comment-strip <FILE_NAME> --backup
  • Process only specific file types:
comment-strip <DIRECTORY_NAME>/ --extensions=js,ts,py
  • Combine options:
comment-strip src/ --type="//" --backup --extensions=js,ts

📝 Command Options

Usage: comment-strip [options] <file|directory>

Options:
  --type <type>,       -t    Comment type to strip: //, #, /* */, --, etc.
  --dry-run,           -d    Preview changes without modifying files
  --backup,            -b    Create backup files before modification
  --extensions <ext>,  -e    File extensions to process (comma-separated)
  --help,              -h    Show help message

🌍 Supported Languages

  • Programming: JavaScript, TypeScript, C, C++, Java, Python, Solidity, Rust, Go, Kotlin, Swift, Dart, Scala

  • Web: CSS, SCSS, HTML, JSON

  • Config: Docker, CMake, TOML, YAML, INI, Makefile

  • Database: SQL

📋 Examples

JavaScript – Strip // and /* */ Comments

  • Before
// This is a single-line comment
const url = "https://example.com"; // Inline comment

/*
  This is a multi-line comment
*/
function greet(name) {
  console.log("Hello, " + name); // Greet user
}
comment-strip app.js
  • After
const url = "https://example.com";

function greet(name) {
  console.log("Hello, " + name);
}

🐍 Python – Strip # Comments

  • Before
# Import the OS module
import os

def say_hello(name):  # This function greets
    message = f"Hello, {name}"  # Format the message
    print(message)  # Display
comment-strip script.py --type="#"
  • After
import os

def say_hello(name):
    message = f"Hello, {name}"
    print(message)

Solidity – Strip // and /* */ but Preserve SPDX & NatSpec

  • Before
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Greeter Contract
contract Greeter {
    string public greeting; // Stores greeting

    constructor(string memory _greeting) {
        greeting = _greeting; // Set greeting
    }

    /* This function returns the greeting */
    function greet() public view returns (string memory) {
        return greeting;
    }
}
comment-strip Greeter.sol
  • After
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Greeter {
    string public greeting;

    constructor(string memory _greeting) {
        greeting = _greeting;
    }

    function greet() public view returns (string memory) {
        return greeting;
    }
}

🔒 Special Handling

  • Preserves SPDX licenses in Solidity files

  • Preserves shebangs (#!/usr/bin/env python3)

  • Preserves docstrings in Python

  • Handles comments inside strings correctly

  • Supports regex literals in JavaScript

🤝 Contributing

  • Fork the repository

  • Create your feature branch (git checkout -b feature/amazing-feature)

  • Commit your changes (git commit -m 'Add amazing feature')

  • Push to the branch (git push origin feature/amazing-feature)

  • Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐️ Star it. Strip it. Ship it.

🖤 Built with passion using Node.js, for minimalists and CLI lovers