Homebrew Taking Up Too Much Space? Complete Cleanup Guide

Updated January 2025 -- Covers Homebrew 4.x on macOS (Apple Silicon + Intel)

5--30+ GB

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.

Table of Contents

  1. Where Homebrew Stores Data
  2. Check Homebrew Disk Usage
  3. brew cleanup -- The Essential Command
  4. Remove Orphaned Dependencies
  5. Clean the Download Cache
  6. Remove Old Formula Versions
  7. Clean Up Cask Downloads
  8. Find Your Largest Packages
  9. Automate Homebrew Cleanup
  10. See All Developer Caches at Once

1. Where Homebrew Stores Data

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/
The download cache is the sneaky one. Every bottle (pre-compiled formula) and cask you've ever installed gets cached at ~/Library/Caches/Homebrew/. This includes old versions of Chrome, VS Code, Docker Desktop, and every other cask -- even after you've updated them.

2. Check Homebrew Disk Usage

# 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)"

3. brew cleanup -- The Essential Command

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:

Always run 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.

4. Remove Orphaned Dependencies

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
How this happens: You install 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.

5. Clean the Download Cache

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/
Tip: If you delete the cache, Homebrew will re-download packages the next time you install or upgrade them. This is safe -- it just means slightly slower installs next time.

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

6. Remove Old Formula 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

Common Disk-Heavy Formulas

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
Pro tip: If you installed something like llvm for a one-time project, consider uninstalling it: brew uninstall llvm. It'll save 1.5GB and you can always reinstall later.

7. Clean Up Cask Downloads

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

8. Find Your Largest Packages

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

9. Automate Homebrew Cleanup

Auto-cleanup on every install

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
Homebrew 4.x runs 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.

Cron job for deep cleanup

# 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

One-liner for maximum cleanup

# The ultimate Homebrew cleanup command
brew update && brew upgrade && brew autoremove && brew cleanup --prune=all && rm -rf ~/Library/Logs/Homebrew/

10. See All Developer Caches at Once

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.

ClearDisk -- See Everything in Your Menu Bar

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

View on GitHub | Download DMG


Quick Reference

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