Typical disk space consumed by Homebrew on a developer Mac
Homebrew is the most popular package manager for macOS, but it quietly accumulates old formula versions, downloaded packages, cask DMGs, and orphaned dependencies. Most developers never clean it up.
This guide covers everything: where Homebrew stores data, how to check what's taking space, and how to safely clean it all.
Homebrew stores data in different locations depending on your Mac's architecture:
| Location | Apple Silicon (M1+) | Intel Mac |
|---|---|---|
| Homebrew prefix | /opt/homebrew/ |
/usr/local/ |
| Installed formulas | /opt/homebrew/Cellar/ |
/usr/local/Cellar/ |
| Installed casks | /opt/homebrew/Caskroom/ |
/usr/local/Caskroom/ |
| Download cache | ~/Library/Caches/Homebrew/ |
|
| Logs | ~/Library/Logs/Homebrew/ |
|
~/Library/Caches/Homebrew/. This includes old versions of Chrome, VS Code, Docker Desktop, and every other cask -- even after you've updated them.
# Total Homebrew installation size
du -sh $(brew --prefix)
# Download cache size (this is usually the biggest)
du -sh ~/Library/Caches/Homebrew/
# Cellar (installed formulas) size
du -sh $(brew --cellar)
# Caskroom (installed casks) size
du -sh $(brew --prefix)/Caskroom/ 2>/dev/null
# Logs
du -sh ~/Library/Logs/Homebrew/ 2>/dev/null
# All at once
echo "=== Homebrew Disk Usage ==="
echo "Prefix: $(du -sh $(brew --prefix) 2>/dev/null | cut -f1)"
echo "Cache: $(du -sh ~/Library/Caches/Homebrew/ 2>/dev/null | cut -f1)"
echo "Cellar: $(du -sh $(brew --cellar) 2>/dev/null | cut -f1)"
echo "Logs: $(du -sh ~/Library/Logs/Homebrew/ 2>/dev/null | cut -f1)"
The most important command to know:
# See what would be cleaned (dry run)
brew cleanup -n
# Actually clean: removes old versions + stale downloads
brew cleanup
# Aggressive: also remove downloads older than 120 days
brew cleanup --prune=all
What brew cleanup removes:
brew cleanup -n first to see what will be removed. The output might surprise you -- it's not uncommon to see 5-15GB of reclaimable space.
When you uninstall a formula, its dependencies stay behind. Over time, these orphans accumulate:
# List orphaned dependencies (installed as deps but no longer needed)
brew autoremove --dry-run
# Remove them
brew autoremove
# Alternative: see what depends on what
brew deps --installed --tree
imagemagick (which pulls in libpng, libtiff, freetype, etc.), use it for a project, then uninstall it. The dependencies stay. Do this 20 times over a year and you have dozens of orphaned packages.
The Homebrew download cache often holds gigabytes of old downloads:
# Check cache size
du -sh ~/Library/Caches/Homebrew/
# List cached downloads sorted by size
ls -lhS ~/Library/Caches/Homebrew/downloads/ 2>/dev/null | head -20
# Remove all cached downloads
brew cleanup --prune=all
# Nuclear: delete the entire cache directory
rm -rf ~/Library/Caches/Homebrew/
Common large items in the cache:
| Package | Typical Cache Size | Why |
|---|---|---|
| Google Chrome (cask) | 200-400 MB per version | Full DMG cached on every update |
| Docker Desktop (cask) | 600 MB-1 GB per version | Large installer cached |
| VS Code (cask) | 100-200 MB per version | ZIP cached monthly |
| node (formula) | 50-100 MB per version | Frequent updates |
| python (formula) | 100-200 MB per version | Major + minor versions |
Homebrew keeps old versions of formulas in the Cellar even after upgrading:
# Find formulas with multiple versions installed
brew list --versions | awk 'NF > 2'
# See old versions of a specific formula
brew list --versions python
# Remove old versions (keeps latest only)
brew cleanup
# Check the Cellar for large formulas
du -sm $(brew --cellar)/*/ 2>/dev/null | sort -rn | head -20
| Formula | Typical Size |
|---|---|
llvm |
1.5-2 GB |
qt / qt@5 |
500 MB-1 GB |
gcc |
500 MB-1 GB |
rust |
400-800 MB |
python@3.x |
100-300 MB |
node |
100-200 MB |
llvm for a one-time project, consider uninstalling it: brew uninstall llvm. It'll save 1.5GB and you can always reinstall later.
Cask downloads (DMGs, PKGs, ZIPs) from apps like Chrome, Docker, Slack, etc. are cached separately:
# List installed casks
brew list --cask
# Check if any casks have outdated versions in Caskroom
ls $(brew --prefix)/Caskroom/*/
# Clean up outdated cask downloads
brew cleanup --cask
# List cask cache specifically
ls -lhS ~/Library/Caches/Homebrew/Cask/ 2>/dev/null
Quick script to find your largest Homebrew packages:
# Top 15 largest formula installs
echo "=== Largest Formulas ==="
du -sm $(brew --cellar)/*/ 2>/dev/null | sort -rn | head -15
# Top 10 largest cask installs
echo "=== Largest Casks ==="
for cask in $(brew list --cask 2>/dev/null); do
size=$(du -sm $(brew --prefix)/Caskroom/$cask/ 2>/dev/null | cut -f1)
echo "${size:-0} $cask"
done | sort -rn | head -10
# Top 10 largest cache files
echo "=== Largest Cached Downloads ==="
du -sm ~/Library/Caches/Homebrew/downloads/* 2>/dev/null | sort -rn | head -10
Add this to your ~/.zshrc (or ~/.bashrc):
# Auto-cleanup after every brew install/upgrade
export HOMEBREW_CLEANUP_MAX_AGE_DAYS=30
export HOMEBREW_AUTOREMOVE=1
brew cleanup automatically after brew install and brew upgrade by default. But it only removes downloads older than 120 days. Setting HOMEBREW_CLEANUP_MAX_AGE_DAYS=30 makes it more aggressive.
# Add to crontab (crontab -e)
# Every Sunday at 2 AM: full Homebrew cleanup
0 2 * * 0 /opt/homebrew/bin/brew cleanup --prune=all >> /tmp/brew-cleanup.log 2>&1
# The ultimate Homebrew cleanup command
brew update && brew upgrade && brew autoremove && brew cleanup --prune=all && rm -rf ~/Library/Logs/Homebrew/
Homebrew is just one piece of the puzzle. On a typical developer Mac, you also have caches from:
Together these can add up to 50-300GB of reclaimable space.
Free, open-source macOS app that detects Homebrew cache alongside Xcode, node_modules, Docker, pip, CocoaPods, Cargo, and 10+ more locations. Shows real-time sizes -- clean what you want, keep what you need.
brew tap bysiber/cleardisk && brew install --cask cleardisk
| Task | Command |
|---|---|
| Preview cleanup | brew cleanup -n |
| Basic cleanup | brew cleanup |
| Aggressive cleanup | brew cleanup --prune=all |
| Remove orphan deps | brew autoremove |
| Check cache size | du -sh ~/Library/Caches/Homebrew/ |
| Delete entire cache | rm -rf ~/Library/Caches/Homebrew/ |
| Find large packages | du -sm $(brew --cellar)/*/ | sort -rn | head -15 |
| Full cleanup | brew update && brew upgrade && brew autoremove && brew cleanup --prune=all |
| GUI cleanup (all caches) | brew tap bysiber/cleardisk && brew install --cask cleardisk |