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 🙏

© 2025 – Pkg Stats / Ryan Hefner

deps-janitor

v0.1.1

Published

Interactive tool to find and remove unused npm dependencies

Readme

deps-janitor 🧹

Your friendly dependency cleaner! Sweeps away unused npm packages so your project stays tidy.

Why "Janitor"?

Because janitors clean up messes → unused deps are messes → deps-janitor cleans them up. Simple!

Features

  • 🧹 Smart Sweeping: Finds truly dusty (unused) dependencies in your codebase
  • 🔍 Thorough Inspection: Checks imports, requires, dynamic imports, and subpaths
  • 🏷️ VIP Treatment: Recognizes special packages (build tools, configs, types)
  • 💬 Friendly Chat: Interactive prompts with personality
  • 🛠️ Multi-Tool Support: Works with npm, yarn, and pnpm
  • 🏢 Building Aware: Basic monorepo support
  • 👀 Inspection Mode: Dry-run to see what would get the boot
  • Quick Work: Caches files for speedy cleaning

Installation

Global Installation

npm install -g deps-janitor

Local Installation

npm install --save-dev deps-janitor

Usage

Basic Usage

deps-janitor

Options

deps-janitor --dry-run    # Preview what would be removed
deps-janitor --debug      # Show detailed analysis
deps-janitor --help       # Show help

As npm script

Add to your package.json:

{
  "scripts": {
    "cleanup-deps": "deps-janitor"
  }
}

Then run:

npm run cleanup-deps

Configuration

Create a .cleanupdepsrc or .cleanupdepsrc.json file in your project root to customize which packages to keep:

{
  "ignore": ["eslint", "prettier"],
  "ignorePatterns": ["@types/*", "*-loader"]
}

Quick start: Copy the included .cleanupdepsrc.example file to .cleanupdepsrc and customize it for your project:

cp .cleanupdepsrc.example .cleanupdepsrc

Configuration Options

  • ignore: Array of package names to always keep (exact matches)
  • ignorePatterns: Array of glob patterns for packages to ignore (supports wildcards)

How It Works

  1. File Scanning: Scans your project files (excluding node_modules, .git, etc.)
  2. Import Analysis: Looks for various import patterns:
    • ES6 imports: import ... from 'package'
    • CommonJS: require('package')
    • Dynamic imports: import('package')
    • Subpath imports: from 'package/subpath'
  3. Special Cases: Checks for config files and build tools
  4. Script Analysis: Verifies usage in npm scripts
  5. Interactive Removal: Prompts for confirmation before removing packages

Supported Package Managers

  • npm
  • yarn
  • pnpm

The tool automatically detects your package manager based on lock files.

Examples

Basic cleanup

$ deps-janitor
🧹 deps-janitor reporting for duty!
🏢 Building: my-awesome-app
🛠️  Tools: npm

🧹 Checking the halls for messes...
🗂️  Found 45 files to inspect

🔍 Time to sweep for dusty packages...
🧹 Swept through 23 packages

🗂️  Found 3 dusty packages collecting cobwebs:
  1. 📦 lodash
  2. 📦 moment
  3. 📦 unused-package

🧹 Clean sweep? Remove all dusty packages? (y/n): y
🗑️  Tossing: npm uninstall lodash
✨ lodash swept away!

Inspection mode

$ deps-janitor --dry-run
👀 INSPECTION MODE - Just checking, no cleaning yet

👀 [INSPECTION] Would toss: lodash
👀 [INSPECTION] Would toss: moment

🧹 Cleaning Report:
🗑️  Tossed: 2
✨ Kept tidy: 21
⏭️  Skipped: 0

License

MIT

Contributing

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