Skip to content

Is It Safe to Delete Library Caches on Mac? Yes, Mostly

Is it safe to delete Library caches on Mac? Mostly yes. What to clear, what to keep, and how to clear Homebrew, npm, pnpm, Yarn, pip and uv caches.

Updated · 7 min read

Yes, it is safe to delete Library caches on a Mac, as long as you quit the apps that own them and delete the contents of ~/Library/Caches, not system folders. Caches hold data apps can rebuild, so the only cost is slower first launches and re-downloads. For Homebrew, npm, pip and uv, use each tool’s clean command.

TL;DR

  • See what’s big: du -sh ~/Library/Caches/* 2>/dev/null | sort -h | tail -15
  • Quit the app, then delete its folder: rm -rf ~/Library/Caches/<folder>
  • Homebrew: brew cleanup (preview with brew cleanup -n)
  • npm: npm cache clean --force; pnpm: pnpm store prune
  • pip: pip3 cache purge; uv: uv cache prune or uv cache clean

What is ~/Library/Caches?

~/Library/Caches is where macOS apps keep data they can recreate: downloaded images, compiled shaders, web caches, package downloads and similar. Apple’s guidance to developers is that anything in Caches must be regenerable, because the system or the user may remove it. That is what makes it safe to clear.

There are actually several cache locations on a Mac:

Path What it is Safe to delete? How it comes back
~/Library/Caches Your apps’ caches Yes, contents, with apps quit Apps rebuild on next use
~/Library/Containers/<app>/Data/Library/Caches Caches of sandboxed (App Store) apps Yes, with the app quit App rebuilds on next use
/Library/Caches System-wide caches shared by all users Leave it; usually small macOS and installers manage it
/private/var/folders/.../C Per-user cache managed by macOS No, don’t touch by hand macOS manages it
/System/Library/Caches Part of macOS Never Protected by the system

You can print the per-user system cache path with getconf DARWIN_USER_CACHE_DIR. It is useful to know where it is, but macOS cleans it on its own.

How to see what is using space in Library caches

These commands only read sizes:

# Total
du -sh ~/Library/Caches

# Biggest subfolders, largest last
du -sh ~/Library/Caches/* 2>/dev/null | sort -h | tail -15

Folder names are usually the app’s bundle identifier (com.spotify.client, com.apple.Safari) or the tool’s name (Homebrew, pip, pnpm). On developer Macs the top of the list tends to be package managers, Swift Package Manager (org.swift.swiftpm), browsers and chat apps.

If du reports “Operation not permitted”, Terminal doesn’t have Full Disk Access. You can grant it in System Settings > Privacy & Security > Full Disk Access, or accept that a few protected folders are skipped.

How to clear Library caches safely

  1. Quit the app whose cache you are clearing. Deleting a cache while the app is writing to it can make the app misbehave until it restarts.
  2. Delete the subfolder, not ~/Library/Caches itself:
du -sh ~/Library/Caches/com.spotify.client
rm -rf ~/Library/Caches/com.spotify.client
  1. Open the app again. It recreates the folder.

If you prefer something reversible, drag the folders to the Trash in Finder instead (press Command-Shift-G and enter ~/Library/Caches), use the app for a day, then empty the Trash.

Avoid one-liners like sudo rm -rf /Library/Caches/* or anything under /System. The system-wide caches are small on most Macs, and the risk isn’t worth it.

Developer caches: how to clear each one

Package managers keep their caches in ~/Library/Caches or in dot folders in your home directory. Every one of them has a command that prints the cache location and a command that cleans it. Use those instead of guessing paths.

How to clear the Homebrew cache

brew --cache          # usually ~/Library/Caches/Homebrew
brew cleanup -n       # dry run: show what would be removed
brew cleanup          # remove outdated downloads and old formula versions

brew cleanup removes downloads older than 120 days (configurable with HOMEBREW_CLEANUP_MAX_AGE_DAYS) and old versions of installed formulae, so it often frees more than the cache folder’s size suggests. To remove every cached download regardless of age, use brew cleanup --prune=all. Homebrew’s own help notes that downloads for installed formulae are kept even by --scrub, and that rm -rf "$(brew --cache)" is the way to remove those too.

How to clear the npm cache on Mac

npm config get cache                       # usually ~/.npm
du -sh ~/.npm/_cacache ~/.npm/_npx         # package cache and npx downloads
npm cache verify                           # garbage-collect and check integrity
npm cache clean --force                    # delete the cache

npm’s cache is content-addressed and self-healing, so npm makes you add --force to clean it; the only good reason is reclaiming space. npm cache verify is the gentler option, removing data npm no longer needs. The _npx folder holds packages downloaded by npx and can be large. Delete it with rm -rf ~/.npm/_npx and npx will download again on next use.

How to clear the pnpm store

pnpm store path       # e.g. ~/Library/pnpm/store/v10
pnpm store prune      # remove packages no project references

pnpm keeps one copy of each package version in a global store and hard-links it into each project’s node_modules. Two consequences: du on several projects counts the same files more than once, and deleting a project’s node_modules frees less than its apparent size. pnpm store prune removes packages that no project references any more. pnpm also keeps package metadata in ~/Library/Caches/pnpm on most setups, which is safe to delete.

How to clear the yarn cache

Yarn wasn’t installed on the Mac this guide was tested on, so check with your own version:

yarn --version
yarn cache dir         # Yarn 1 (classic): prints the cache location
yarn cache clean       # Yarn 1: clear it
yarn cache clean --all # Yarn 2+ (Berry): clear the global cache too

On most setups Yarn 1 stores its cache under ~/Library/Caches/Yarn, and Yarn 2+ keeps a global cache under ~/.yarn/berry/cache plus optional per-project caches in .yarn/cache. Don’t delete a project’s .yarn/cache if the project commits it for zero-installs.

How to clear the pip cache on Mac

pip3 cache dir        # usually ~/Library/Caches/pip
pip3 cache info       # size of HTTP cache and locally built wheels
pip3 cache purge      # remove everything

Use pip3 cache remove <package> to drop a single package’s wheels instead of everything. Each Python install has its own pip, but they share the same cache directory by default.

How to clear the uv cache

uv cache dir                      # usually ~/.cache/uv
du -sh "$(uv cache dir)"
uv cache prune                    # remove unused entries
uv cache clean                    # remove everything
uv cache clean requests           # remove one package

uv cache prune removes dangling entries and is safe to run any time. uv cache clean empties the cache; uv re-downloads on the next install. Close running Python processes that use uv-managed environments first; both commands have a --force flag that skips uv’s in-use check, which you shouldn’t need.

Swift Package Manager and Xcode

Swift Package Manager keeps cloned repositories, manifests and binary artifacts in ~/Library/Caches/org.swift.swiftpm. With Xcode quit, deleting it is safe; packages are fetched again on the next resolve. Xcode’s per-project package checkouts and build data live in DerivedData instead, covered in how to delete Xcode DerivedData.

Quick reference

Tool Find the cache Clear it What comes back
Homebrew brew --cache brew cleanup / --prune=all Downloads on next install or upgrade
npm npm config get cache npm cache clean --force Packages on next npm install
pnpm pnpm store path pnpm store prune Packages on next pnpm install
Yarn yarn cache dir (v1) yarn cache clean Packages on next yarn install
pip pip3 cache dir pip3 cache purge Wheels on next pip install
uv uv cache dir uv cache clean Packages on next uv sync / uv pip install
SwiftPM ~/Library/Caches/org.swift.swiftpm Delete with Xcode quit Repos on next package resolve

How often should you clear caches?

You don’t need a schedule. Caches make installs and launches faster, so clearing them constantly costs you time. Clear them when you are short on space, when a package manager behaves strangely, or after you stop using a tool entirely. Note that clearing a cache doesn’t touch installed dependencies: node_modules folders are separate and are often bigger. See how to delete node_modules recursively on Mac.

Do it in one click with DevCleanup

DevCleanup’s Smart Clean finds Library caches, app and browser caches, logs and package-manager caches (npm, pnpm, Bun, Gradle, Cargo, ~/.cache) in one scan, and it’s free. Large AI model downloads in ~/.cache are left out of it on purpose and shown on the AI Models screen instead, so a cache cleanup never deletes a 5 GB model. Everything it removes is logged in History, and it never deletes a git repo. Caches are one part of the picture; Space Lens shows the rest of your disk.

Download DevCleanup. Scanning is free; Pro ($29 one-time) unlocks the developer cleanup actions. If caches are only part of your problem, read Mac System Data too large and how to free up space on Mac as a developer.

Frequently asked questions

Is it safe to delete ~/Library/Caches on a Mac?

Yes, for the contents, with the apps that own them quit. Caches hold data apps can recreate, so the cost is slower first launches and re-downloads. Delete the subfolders inside ~/Library/Caches rather than the Caches folder itself, and never delete anything under /System.

How do I clear the Homebrew cache?

Run brew cleanup -n to preview, then brew cleanup to remove outdated downloads and old formula versions. brew cleanup --prune=all removes all cached downloads regardless of age. The cache lives at the path printed by brew --cache, usually ~/Library/Caches/Homebrew.

How do I clear the npm cache on a Mac?

Run npm cache clean --force. npm requires --force because its cache is self-healing and rarely needs clearing except to reclaim space. The cache lives in ~/.npm by default; the _npx folder next to it holds packages downloaded by npx and can be deleted separately.

Will deleting caches break my apps or projects?

No. Apps rebuild caches as needed, and package managers re-download anything missing on the next install. You may see a slower first launch, a slower first install, or occasionally an app asking you to sign in again.