How to clean the Homebrew cache on Mac safely
Use Homebrew's own cleanup command so it can distinguish stale downloads and old formula versions from files your current installation needs.
brew cleanup --dry-run first. Review the list, then run brew cleanup. Homebrew documents the cache at ~/Library/Caches/Homebrew by default on macOS, but brew --cache is the reliable way to find it.Inspect before deleting
brew --cache brew cleanup --dry-run du -sh "$(brew --cache)"
The first command prints the active cache directory. The second previews stale downloads, locks, and old installed formula versions. The third only measures that directory. None removes data.
Choose the smallest cleanup
| Command | What it does | When to use it |
|---|---|---|
brew cleanup | Removes stale downloads and old formula versions under Homebrew's rules. | Routine cleanup. |
brew cleanup package | Limits cleanup to one formula or cask. | You want narrow scope. |
brew cleanup --prune=all | Prunes all eligible cached files regardless of age. | Disk pressure is urgent and downloads can be fetched again. |
brew autoremove --dry-run | Previews dependencies no installed formula needs. | After removing many formulae. |
brew --cache.What can be deleted—and what changes afterward?
Cached bottles and source archives can be downloaded again. Old installed formula versions are normally safe to remove after confirming the current version works. Cleanup does not remove your current requested formulae, project source code, or configuration files in your home directory.
If you work offline, are debugging an older bottle, or need an immediate rollback, keep the relevant download or old keg until that work is complete. Review brew autoremove --dry-run carefully: it concerns installed dependencies, not merely downloads.
GUI alternative
- In Finder choose Go → Go to Folder.
- Paste the result of
brew --cache. - Inspect large downloads, but prefer
brew cleanupso Homebrew decides what is stale.
Where Homebrew fits in developer storage
Homebrew is only one source. Xcode simulators, archives, Docker images, npm caches, and dependency trees are separate. Use the Mac developer cache guide, or see how to reclaim Docker storage and delete Xcode Derived Data.
Prefer a visual review?TrimyMac can surface cache and developer-storage candidates for review before cleanup.
Source
Commands and defaults were checked against the official Homebrew manual on September 14, 2026.