Reclaim Disk Space from Homebrew
14 Apr 2026Homebrew keeps every old version of every formula it’s ever installed, plus a full download cache, and never deletes any of it on its own. On a machine that’s a year or two old, that’s easily 10-20GB of dead weight.
Check what it’s actually using first
du -sh $(brew --cache)
du -sh $(brew --prefix)/Cellar
brew --cache is the download cache — every .tar.gz for every formula and version you’ve ever installed, kept indefinitely in case you reinstall. Cellar is where the actual installed versions live, old ones included.
The one command that does most of the work
brew cleanup
Removes old versions of installed formulae and clears the download cache for anything no longer needed. This alone usually recovers several gigabytes. Run it with -n first to preview without deleting anything:
brew cleanup -n
Cleanup has a default retention window — override it for a full sweep
By default, brew cleanup skips anything downloaded in the last 120 days, on the assumption you might revert to it. To actually clear everything:
HOMEBREW_CLEANUP_MAX_AGE_DAYS=0 brew cleanup
Only do this if you’re not mid-troubleshoot on a formula you might need to downgrade — once it’s gone, reinstalling means a full re-download.
Find what’s actually orphaned
brew autoremove
Removes dependencies that were pulled in automatically for a formula you’ve since uninstalled. brew install postgresql pulls in icu4c, readline, and others — uninstall postgres later and those often stick around unless you run this.
Find formulae nothing depends on and you forgot you installed
brew leaves
Lists formulae that aren’t a dependency of anything else — the actual top-level things you asked for. Cross-reference against what you remember using; anything you don’t recognize is a candidate for brew uninstall.
Check for broken or duplicate installs
brew doctor
Surfaces stale symlinks, permission issues, and installs Homebrew itself flags as problematic — not disk space directly, but often the root cause of “why did installing this formula fail halfway and leave garbage behind.”
Cache to check separately: Homebrew Cask
If you install GUI apps via brew install --cask, those download .dmg/.pkg files into the same cache and are just as easy to forget:
brew list --cask
brew cleanup covers casks too, but a brew list --cask pass is worth doing manually — this is where people find a 4GB Xcode-adjacent installer they downloaded once, two years ago, for a task they don’t remember.
Full reclaim, one line
brew autoremove && brew cleanup -s
-s scrubs the cache more aggressively, including files for formulae still installed (their download archive, not the install itself — you lose the ability to reinstall from cache, not the working install).
What this doesn’t touch
Homebrew cleanup only manages what Homebrew itself installed. It won’t touch:
- Xcode and its simulators (
xcrun simctl delete unavailableis the equivalent cleanup there) - Docker images and volumes (
docker system prune) - npm/yarn/pip global caches (each has its own
cache cleancommand)
If you’re chasing disk space and Homebrew cleanup didn’t move the needle much, those are usually the next place to look — they accumulate the same way, independently.
Put it on a schedule instead of remembering
# crontab -e, run weekly
0 9 * * 1 /opt/homebrew/bin/brew cleanup -q
Cheaper than doing a panicked full sweep once a year when your disk is actually full.