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

find-unused-images

v1.2.0

Published

Find unused images in your project

Readme

🧹 Find Unused Images

A simple Node.js CLI tool that detects and removes unused image files from your codebase. It scans your project for images (e.g., .png, .svg, .webp) and checks for references in your source files (e.g., .js, .vue, .html, etc).

This tool is perfect for cleaning up unused assets, whether you’re working on a frontend or backend project.


✨ Features

  • Detects unused image files across popular frameworks
  • Supports a wide range of static and asset folders
  • Uses a default configuration that covers the most common file structures
  • Outputs a clear, formatted list of unused images with file paths
  • Scans JSON files for image references
  • Automatically ignores common directories like node_modules, .git, .next, etc.

⚙️ Frameworks Supported

Frontend:

  • React (CRA, Vite)
  • Next.js
  • Vue 2/3 (Vue CLI, Vite)
  • Angular
  • Svelte / SvelteKit

Backend:

  • Laravel (PHP)
  • Django (Python)
  • Flask (Python)
  • ASP.NET Core
  • Express.js
  • Ruby on Rails

📦 Installation

Install as a development dependency:

npm install find-unused-images --save-dev

Usage

After installation, you can execute by running the following command from your terminal:

npx find-unused-images

🔧 Default Configuration

The script is preconfigured with sensible defaults that cover a wide range of frameworks and file structures. By default, it will:

📁 Search the following directories for image files:

  • ./public/images
  • ./src/assets/images
  • ./static/images
  • ./src/lib/assets/images
  • ./wwwroot/images
  • ./storage/app/public
  • ./uploads
  • ./media
  • ./app/assets/images

🖼️ Look for image file types:

  • .png, .jpg, .jpeg, .gif, .svg, .webp

🧠 Scan code files with the following extensions for references:

  • .js, .jsx, .ts, .tsx, .vue, .svelte
  • .html, .css, .blade.php, .cshtml, .py, .rb, .php
  • .json (for image references in JSON data files)

🚫 Automatically ignored directories and files:

  • node_modules
  • .git
  • .next
  • dist and build
  • .cache
  • coverage
  • .DS_Store
  • Lock files (package-lock.json, yarn.lock, pnpm-lock.yaml)

The search will include all these folders and file types by default. There's no additional configuration required on your part.

Example

$ find-unused-images
Generated file patterns [
  '**/*{.js,.jsx,.ts,.tsx,.vue,.blade.php,.html,.css,.json}',
  '*{.js,.jsx,.ts,.tsx,.vue,.blade.php,.html,.css,.json}'
]
Found 150 image files.
Scanning 50 code files.
Unused images:
- 'public/images/logo.png'
- 'src/assets/bg.jpg'

🧠 How It Works

  1. It uses fast-glob to recursively scan all default directories for image files.
  2. It scans all project files (except ignored directories) for code files that might reference images.
  3. It reads the content of every matched code file and checks whether any image filenames appear in the code.
  4. Image references can be:
    • Direct (e.g., src="logo.png")
    • Inside custom component attributes (e.g., <Image src="logo" />)
    • Inside JSON data files (e.g., { "image": "logo" })
  5. Any image file that is not referenced in any code file is marked as unused.
  6. A list of these unused image file paths is printed to the console for review and cleanup.

🧬 Code Overview

  • Image Matching: fast-glob scans all default image folders for file extensions like .png, .jpg, .svg, etc.
  • Code Scanning: The tool scans all project files (except ignored directories) for any references to the image file names.
  • JSON Support: Special handling for JSON files to find image references in data structures.
  • Tracking Usage: A Set is used to track which image files are actually referenced in the codebase.
  • Filtering Unused: The final list of unused images is computed by comparing all found image files against those marked as used.

No manual config or prompts required — the scan is fully automatic based on the built-in defaults.

Development

If you'd like to contribute to the project or modify it, feel free to clone the repo and make your changes.

  1. Clone the repo:
git clone https://github.com/your-username/find-unused-images.git
  1. Install dependencies:
npm install
  1. Make your changes and submit a pull request.

License

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