Your package manager is a hoarder: cleaning up Homebrew on Mac

Updated September 2026 · 6 min read

Homebrew is the first thing most developers install on a new Mac — and one of the last things they ever clean. Every update downloads a new version of a package but keeps the old one "just in case." Every formula you tried once and forgot about stays installed with all its dependencies. Over months, this quiet accumulation can claim 5–15 GB.

The good news: Homebrew has built-in cleanup commands. You just have to remember to run them.

Where Homebrew stores things

Homebrew keeps everything under its prefix — /opt/homebrew on Apple Silicon Macs, /usr/local on Intel. The biggest folders:

LocationWhat's inside
Cellar/Installed formula versions (including old ones)
Caskroom/Installed cask app versions
Library cache (~/Library/Caches/Homebrew)Downloaded tarballs and bottles

Step 1: Clean up old versions and downloads

The single most useful command:

brew cleanup

This removes old versions of installed formulas, outdated downloads from the cache, and stale lock files. It's safe — it never touches the current version of anything you have installed.

Want to see what it would remove before committing?

brew cleanup --dry-run

This lists everything that would be deleted without actually deleting it. A good first step if you're cautious.

Step 2: Remove orphaned dependencies

When you uninstall a formula, its dependencies stay behind — even if nothing else needs them. To clean those up:

brew autoremove

This removes formulas that were installed only as dependencies and are no longer required by anything. It's the Homebrew equivalent of picking up after yourself.

Step 3: Find formulas you forgot about

Over time, you install tools for one-off tasks and never use them again. To see everything you explicitly installed (not auto-installed as a dependency):

brew leaves

Scan the list. If you see something you don't recognize or haven't used in months, uninstall it:

brew uninstall formula-name

Then run brew autoremove again to clean up any dependencies it left behind.

When not to do this: don't uninstall formulas if you're not sure what they do — some are dependencies for tools that don't show up in the dependency tree (scripts, custom workflows). If in doubt, leave it. You can always uninstall later.

Step 4: Clear the download cache entirely

Even after brew cleanup, Homebrew keeps recent downloads in its cache. To wipe it completely:

brew cleanup -s

This removes all cached downloads, including the latest ones. You'll re-download them if you reinstall, but it frees the most space.

How much space does this save?

It depends on how long you've had Homebrew installed and how many packages you use. A Mac that's been running for a year or more with regular brew install usage typically recovers 3–10 GB from cleanup alone. Developers who use many build tools can see even more.

Homebrew is just one layer. If you also use npm, pip, Docker, or Xcode, each has its own cache pile — see our full developer caches guide for the complete picture.

Make it automatic

You can set Homebrew to clean up automatically after every install by setting an environment variable in your shell profile:

export HOMEBREW_CLEANUP_MAX_AGE_DAYS=30

With this set, Homebrew automatically removes cached files older than 30 days whenever you run brew install or brew upgrade. Set the number to whatever makes sense for you.

Or let Gigatidy take care of it

Gigatidy finds Homebrew leftovers alongside every other cache on your Mac — and cleans them in one pass, with your approval.

Meet Gigatidy →

FAQ

Does brew cleanup remove currently installed packages?

No. It only removes outdated versions and cached downloads. The current version of every installed formula and cask stays untouched.

Is it safe to run brew autoremove?

Yes. It only removes formulas that were installed automatically as dependencies and are no longer needed by any package you explicitly installed. It won't remove anything you installed yourself.

How often should I clean up Homebrew?

Once a month is a good rhythm if you install or update packages regularly. Setting the HOMEBREW_CLEANUP_MAX_AGE_DAYS variable automates it so you don't have to think about it.