Homebrew rarely deletes anything right away. It keeps the bottles and cask installers it downloaded, the old version of a formula after an upgrade until the next cleanup, and every dependency of a formula you uninstalled. On a Mac used for a few years, that is often several GB.
Three places hold it:
- The download cache:
~/Library/Caches/Homebrew(brew --cacheprints it). Bottles, source archives and cask installers (.dmg,.pkg,.zip). - The Cellar:
/opt/homebrew/Cellaron Apple silicon,/usr/local/Cellaron Intel. One folder per formula, one subfolder per installed version. - The Caskroom:
/opt/homebrew/Caskroom(or/usr/local/Caskroom). Homebrew’s record of each cask app and its version.
See how big they are:
du -sh "$(brew --cache)" "$(brew --prefix)/Cellar" "$(brew --prefix)/Caskroom" 2>/dev/null
brew cleanup
brew cleanup -n # dry run: what would go, and how much
brew cleanup # old formula versions, stale downloads, downloads older than 120 days
brew cleanup --prune=all # also every cached download, whatever its age
brew cleanup removes old versions of formulae (only the newest stays in the Cellar), stale lock files and outdated downloads of formulae and casks. --prune=all empties the download cache too: nothing installed breaks, but a reinstall downloads again. Name a formula or cask (brew cleanup node) to clean only that one.
brew autoremove
brew autoremove -n # dry run: formulae installed only as dependencies that nothing needs any more
brew autoremove
When you uninstall a formula, the dependencies it pulled in stay. brew autoremove removes those no installed formula needs. Read the dry run first: a tool you started using directly but never installed by name would go too (brew install it by name to keep it).
Old versions
brew list --versions # formulae with every installed version
brew list --versions --cask # casks with their version
A formula with two versions after its name still has the old one; brew cleanup <formula> removes it. A formula pinned with brew pin keeps its version and is skipped by brew upgrade.
A cask app that updates itself (Chrome, VS Code, Slack) can leave Homebrew’s record on an old version: the app in /Applications is current and the Caskroom folder is small. The cask installers left in the cache are what take space, and brew cleanup removes the outdated ones.
Automatic cleanup
Homebrew cleans the formula you just installed or upgraded, and runs a full brew cleanup every 30 days. To change that, set in your shell profile:
HOMEBREW_NO_INSTALL_CLEANUP=1: never clean after an install or upgrade. Old versions pile up; set it only if you want to be able to go back to them.HOMEBREW_CLEANUP_MAX_AGE_DAYS=30: keep cached downloads 30 days instead of 120.HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: how many days between full cleanups.
If HOMEBREW_NO_INSTALL_CLEANUP is set and you did not mean it, remove it and run brew cleanup.
Uninstalling a cask app
brew uninstall --cask <token> removes the app and Homebrew’s record. --zap also removes the app’s data in ~/Library, which you may want to review first. Dragging a cask app to the Trash leaves the record, and brew upgrade can install it again. See uninstall Mac apps completely.
How CleanMate does it
On a Mac (all macOS features), CleanMate runs Homebrew’s own commands, never with --force or --zap, and shows the sizes Homebrew’s dry runs report.
- Smart Scan › Homebrew (package caches): cleaned with
brew cleanup. The size is whatbrew cleanup --dry-runreports, reused from the last scan while the cache, Cellar and Caskroom are unchanged (up to 6 hours). - Smart Scan › Unused Homebrew dependencies: the formulae
brew autoremove --dry-runlists (no casks), never ticked for you, each with its size in the Cellar. Cleaning runsbrew autoremoveand reports what was really freed. Skipped whilebrewruns. - Maintenance › Update and Clean Homebrew: runs
brew update,brew upgrade --formulaandbrew cleanup --prune=all, in that order. Formulae only, never casks, because a cask upgrade may ask for a password or replace an open app. brew’s output shows live, with how many formulae were upgraded and how much the cleanup freed; the steps are stopped after 15 minutes. - Uninstaller: an app installed with
brew install --caskshows “Homebrew cask (token)”. Uninstalling it moves the app to the Trash, then runsbrew uninstall --cask <token>(no--zap), sobrew upgradedoes not put it back.
The Ubuntu app does not handle Homebrew. For the rest of a developer Mac, see Free up disk space on a Mac as a developer, node_modules and old build folders and old runtime versions. To compare CleanMate with other cleaners, see the comparison.
FAQ
Is brew cleanup safe? Yes. It removes only old versions and downloads; the newest version of everything you installed stays and keeps working.
How much space will brew cleanup free? Run brew cleanup -n --prune=all: its last line says how much. Often a few hundred MB to several GB.
Does brew cleanup remove cask apps? No. It removes old cask downloads, never an installed app.
What is the difference between brew cleanup and brew autoremove? cleanup removes old versions and downloads; autoremove uninstalls formulae that were only dependencies of formulae you removed.

