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

mgx-console-cleaner

v1.0.0

Published

A tool to remove console statements from your code

Readme

console-cleaner

A simple, configurable CLI tool to remove console statements from JavaScript and TypeScript code.

npm version License: MIT

Overview

console-cleaner helps you clean up your code by removing console statements (console.log, console.debug, etc.) from JavaScript and TypeScript files. This is especially useful when preparing your code for production, where debug logs should be removed.

Features

  • 🧹 Removes console statements (log, debug, info, warn, error)
  • 🔍 Configurable via CLI options or config file
  • 📁 Works with both JavaScript and TypeScript
  • 🚫 Supports ignore patterns for excluding files
  • 🔄 Preserves code formatting and structure
  • 🧪 Dry run option to preview changes

Installation

Global Installation

npm install -g console-cleaner

Local Installation (recommended)

npm install --save-dev console-cleaner

Usage

Basic Usage

# If installed globally
console-cleaner

# If installed locally
npx console-cleaner

With Options

# Specify directory to process
npx console-cleaner --dir src

# Ignore specific patterns
npx console-cleaner --ignore "test/**,**/*.spec.ts"

# Dry run (shows what would be removed without changing files)
npx console-cleaner --dry-run

# Use a custom config file
npx console-cleaner --config my-config.json

Configuration

You can configure console-cleaner by creating a .consolecleanerrc.json file in your project root:

{
  "methods": ["log", "debug", "info"],
  "ignorePatterns": ["test/**", "**/*.spec.{js,ts}", "**/*.test.{js,ts}"],
  "directory": "src"
}

Available Configuration Options

| Option | Description | Default | | ---------------- | ---------------------------------- | ------------------------------------------- | | methods | Array of console methods to remove | ["log", "debug", "info", "warn", "error"] | | ignorePatterns | Glob patterns to ignore | [] | | directory | Directory to process | "." (current directory) |

CLI Options

| Option | Description | | ------------------------- | ------------------------------------------------------- | | -c, --config <path> | Path to config file (default: .consolecleanerrc.json) | | -d, --dir <directory> | Directory to process (overrides config) | | -i, --ignore <patterns> | Comma-separated patterns to ignore (overrides config) | | --dry-run | Show what would be removed without changing files | | -v, --version | Show version number | | -h, --help | Show help |

Examples

Remove only console.log and console.debug

// .consolecleanerrc.json
{
  "methods": ["log", "debug"],
  "directory": "src"
}

Ignore test files and preserve console.error

// .consolecleanerrc.json
{
  "methods": ["log", "debug", "info", "warn"],
  "ignorePatterns": ["test/**", "**/*.spec.ts"]
}

Integration with package.json scripts

// package.json
{
  "scripts": {
    "build": "npm run clean-console && tsc",
    "clean-console": "console-cleaner --dir src"
  }
}

Use Cases

  • Pre-production builds: Remove debug logs before deploying
  • Bundle size optimization: Reduce file size by removing console statements
  • Code cleanup: Clean up development logs before committing code
  • Environment-specific builds: Remove logging in production builds while keeping them in development

How It Works

console-cleaner uses Babel to parse your JavaScript and TypeScript files, traverse the AST (Abstract Syntax Tree), and remove console statements based on your configuration. It preserves the original code structure and formatting as much as possible.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

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