SweepBarGet it free

brew cleanup: free the space Homebrew uses on your Mac

By EgeTech LTD · October 6, 2026 · 2 min read

Homebrew leaves things behind. Every upgrade keeps the previous version on disk for a while, and every download stays in a cache. Over a few years of brew upgrade that adds up to gigabytes, and it is the easiest cleanup on this list, because Homebrew has a command for it.

See what it would remove

Start with a dry run. It prints what would go and deletes nothing:

brew cleanup -n

The long form is --dry-run. Read the list, then run the real command.

Clean up

brew cleanup

According to Homebrew’s own description, this removes stale lock files and outdated downloads for all formulae and casks, and removes old versions of installed formulae. It also removes downloads older than 120 days. You can change that limit with the HOMEBREW_CLEANUP_MAX_AGE_DAYS environment variable.

Remove everything in the cache

By default Homebrew keeps recent downloads. To remove the whole cache:

brew cleanup --prune=all

--prune=all removes every cache file regardless of age. Use --prune=30 to remove only files older than 30 days. A related option, -s (also --scrub), scrubs the cache including downloads for even the latest versions.

Remove packages nothing needs

When you uninstall a program, the libraries that came along only to support it often stay. Remove them:

brew autoremove --dry-run
brew autoremove

Again, the dry run first. autoremove uninstalls formulae that were installed only as dependencies of something else and are no longer needed.

Where the cache is

brew --cache

It prints the cache folder, usually ~/Library/Caches/Homebrew. To see its size:

du -sh "$(brew --cache)"

Does Homebrew clean up by itself?

A little. Homebrew runs a cleanup automatically after some installs and upgrades, but not every time, so running it yourself is still worth it. Setting HOMEBREW_NO_INSTALL_CLEANUP turns the automatic cleanup off, which is a reason some machines carry more clutter than others.

What it costs

For everything else that fills a developer Mac, read how to free up disk space as a developer. The package manager caches for JavaScript are covered in the npm guide.

Quick answers

Is brew cleanup safe?

Yes. It removes old versions of formulae you have installed, stale lock files and old downloads. Your current installed packages are not removed.

What is the difference between brew cleanup and brew autoremove?

cleanup removes old versions and cached downloads. autoremove uninstalls packages that were installed only as dependencies and that nothing needs any more.

Where does Homebrew keep its downloads?

Run brew --cache. On a Mac it is usually the Homebrew folder inside ~/Library/Caches.