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

deeconsole

v1.0.2

Published

CLI to strip or comment console statements from project files

Readme

deeconsole

Its a CLI utility for removing or commenting out console.* statements across JavaScript and TypeScript codebases. Designed to be published as an npm package, it supports glob-based file targeting, dry runs, backups, and optional comment-based preservation of log statements.

Installation

You can consume the package globally, as a dev dependency, or via npx:

# Global install (recommended for recurring use)
npm install --global deeconsole

# Project-level dev dependency
npm install --save-dev deeconsole

# On-demand without install
npx deeconsole --help

When installed globally or locally, the CLI executable is named deeconsole.

Usage

Run the command from the project root you want to scan. By default it searches for JavaScript and TypeScript files and removes all console statements.

deeconsole

Core Options

  • -c, --comment – Comment out matching statements instead of deleting them. Each line in the original statement receives a leading // while preserving indentation.
  • -b, --backup – Create a .bak copy alongside every file that is modified.
  • --dry-run – Traverse and report on matches without writing any files. Useful to preview the impact of the run.
  • -p, --pattern <glob...> – One or more glob patterns (via fast-glob) to include. Defaults to **/*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}.
  • -i, --ignore <glob...> – Glob patterns to exclude (defaults include node_modules, build outputs, git metadata, etc.).
  • --cwd <dir> – Base directory for glob resolution (defaults to the current working directory).
  • --verbose – Emit a line for every file that changes, showing the number of statements handled.

Provide multiple patterns by repeating the flag or supplying several values, e.g. deeconsole --pattern "src/**/*.ts" "tests/**/*.ts".

Display the full help with:

deeconsole --help

Examples

Remove console statements from the default set of source files:

deeconsole

Comment out every console.* call in a specific folder while keeping backups:

deeconsole --comment --backup --pattern "src/**/*.ts"

Preview changes without touching files:

deeconsole --dry-run --verbose

Target only tests and ignore snapshot folders:

deeconsole \
  --pattern "tests/**/*.{ts,tsx}" \
  --ignore "**/__snapshots__/**"

For a ready-made Playwright example, run the CLI against samples/playwright-sample.spec.ts.

Behavior

  • Handles all member calls on the global console object (console.log, console.error, etc.).
  • Ensures only standalone expression statements are removed or commented. Calls embedded in larger expressions are reported as skipped to avoid breaking logic.
  • Preserves original line endings and indentation when commenting out statements.
  • Supports modern syntax via Babel parser plugins (JSX, TypeScript, decorators, optional chaining, top-level await, etc.).

Development

pnpm install
pnpm build
pnpm dev  # Watch mode using ts-node-dev

After building, the compiled CLI lives in dist/index.js with the execute bit set by the shebang.

Sample Workflow

  1. Install the package globally: npm install --global deeconsole.
  2. Run deeconsole --dry-run in your project root to see how many statements will be touched.
  3. Execute deeconsole --comment to convert logs into comments for later review, or omit the flag to remove them outright.
  4. Inspect .bak files if you enabled backups, then delete them when satisfied.

License

ISC — feel free to adapt the tool to your workflow.