Developer Tools

How to Uninstall a Homebrew Package on Mac (and Its Dependencies)

Published Nov 3, 2026
Tested on a real Mac. Ran brew list, leaves, uses, deps, info, autoremove --dry-run and cleanup -n on an M3 Mac (macOS 26.6.2, Homebrew 7.0.11); brew uninstall, autoremove and cleanup without dry-run were not executed, so nothing was removed. Test machine: MacBook Air (M3, 16 GB), macOS Tahoe 26.6.2, zsh 5.9.
On this page
  1. Step 1: find the exact package name
  2. Step 2: uninstall the package
  3. Step 3: remove the dependencies with autoremove
  4. Step 4: free the disk space with brew cleanup
  5. Uninstall many packages at once
  6. Common questions

To uninstall a Homebrew package on Mac, run brew uninstall with the package name. Then run brew autoremove to remove the dependencies nothing else needs, and brew cleanup to delete old versions and cached downloads:

brew uninstall <name>
brew autoremove
brew cleanup --prune=all

brew uninstall removes only the package you name. Its dependencies stay installed until you run autoremove. Apps installed with --cask use the same command, plus an optional --zap flag to remove their settings too. Each step is explained below, with real output from my test Mac.

Step 1: find the exact package name

brew uninstall needs the name Homebrew uses, which is not always the app’s name. List what you have:

brew list --formula
brew list --cask

A shorter, more useful list is brew leaves. It shows only the formulae you installed yourself, not the dependencies that came along with them. On my test Mac (MacBook Air M3, macOS Tahoe 26.6.2, Homebrew 7.0.11), brew list --formula had 48 entries, but brew leaves printed only four:

gh
node
node@24
openjdk@25

The other 44 are dependencies. You usually want to uninstall something from the leaves list.

To check a single package before removing it, use brew info:

brew info node
==> node: 24.1.0 → stable 26.13.0_2 (bottled), HEAD
Open-source, cross-platform JavaScript runtime environment
https://nodejs.org/
Aliases: node.js, node@26, nodejs, npm
Installed (on request)
...
==> Installed Versions
node@24 24.22.2_2          (2,103 files, 82.7MB)
node    24.1.0 → 26.13.0_2 (2,460 files, 103.1MB) [Linked]

“Installed (on request)” means you asked for it. Note that node and node@24 are two separate formulae. Uninstalling node does not touch node@24.

Step 2: uninstall the package

For a formula (command-line tool):

brew uninstall node

For a cask (a regular Mac app installed with brew install --cask):

brew uninstall --cask visual-studio-code

brew remove and brew rm are aliases for the same command. I did not run the uninstall on the test Mac. Here are the flags from brew uninstall --help:

FlagWhat it does
--force / -fDeletes all installed versions of a formula, not just the linked one
--zapFor casks: also removes the app’s settings, caches and support files
--ignore-dependenciesUninstalls even if other formulae still depend on it
--cask / --formulaTells brew which kind it is when a name exists as both

If the package is a dependency of something else, brew is built to refuse and name the formula that needs it. That’s what --ignore-dependencies overrides. Only use --ignore-dependencies if you plan to reinstall it right after, because the other formula may stop working.

--zap deserves care. The help text warns it “may remove files which are shared between applications.” Use it when you want an app gone completely, not when you plan to reinstall it and keep your settings.

Step 3: remove the dependencies with autoremove

Uninstalling a package leaves its dependencies behind. brew autoremove deletes any formula that was installed only as a dependency and that no installed formula needs anymore. Preview it first:

brew autoremove --dry-run

On my Mac it printed nothing and finished in 0.27 seconds. Empty output means there are no orphaned dependencies right now. After you uninstall something with many dependencies, the dry run lists each formula it would remove. If the list looks right, run it for real:

brew autoremove

Gotcha: brew deps —tree can show the wrong dependencies

Before removing a dependency by hand, people often check brew deps --tree. I found it can mislead. For my installed node 24.1.0, it showed:

node
├── ...
├── icu4c@79
├── ...
├── openssl@4
│   └── ca-certificates

But brew list --versions showed I had icu4c@77 and openssl@3 installed, not the @79 and @4 versions. Brew even warns about it: “brew deps is not the actual runtime dependencies because —tree was passed!” The tree comes from today’s formula, not from the older version that is actually on disk.

The reliable check goes the other way. Ask which installed formulae use a dependency:

brew uses --installed openssl@3
node

So openssl@3 is still needed by my old node, even though the current node formula no longer lists it. Removing it by hand would break node. Use brew uses --installed before you uninstall any dependency manually, or let autoremove decide.

Step 4: free the disk space with brew cleanup

Uninstalling removes the package from /opt/homebrew/Cellar (or /usr/local/Cellar on Intel). It does not clear the downloaded bottles in Homebrew’s cache. Preview what cleanup would delete:

brew cleanup -n
Warning: Skipping node: most recent version 26.13.0_2 not installed
Warning: Skipping openssl@3: most recent version 3.5.9 not installed
Would remove: /opt/homebrew/Cellar/brotli/1.1.0 (28 files, 1.8MB)
Would remove: /opt/homebrew/Cellar/c-ares/1.34.5 (176 files, 1.1MB)
Would remove: /opt/homebrew/Cellar/libuv/1.51.0 (20 files, 1.2MB)
...
==> This operation would free approximately 40.1MB of disk space.

Two things stand out. First, Homebrew keeps old versions side by side. I had both brotli 1.1.0 and 1.2.1, and cleanup removes the older one. Second, it skips any formula that is outdated, so old versions of node and openssl@3 stay until you upgrade them.

The bigger win is the cache. By default, cleanup only removes cached downloads older than 120 days. Add --prune=all to remove all of them:

du -sh "$(brew --cache)"
brew cleanup --prune=all -n
886M	~/Library/Caches/Homebrew
==> This operation would free approximately 864.6MB of disk space.

On my Mac, plain cleanup would free 40.1 MB, but --prune=all would free 864.6 MB. That’s more than 20 times as much, from one extra flag. The cache only holds installers, so deleting it is safe. Brew downloads a bottle again if you reinstall. If you’re hunting for space beyond Homebrew, see how to find large files on Mac.

Uninstall many packages at once

brew uninstall accepts several names:

brew uninstall gh openjdk@25
brew autoremove

To remove every formula you installed on purpose (the leaves list) and then their dependencies, you can pipe the list in:

brew leaves | xargs brew uninstall
brew autoremove

Run brew leaves on its own first and read the list. This was not executed on the test Mac. It removes brew packages only. Homebrew itself stays installed. Removing Homebrew completely uses a separate uninstall script from the Homebrew project.

Common questions

Does brew uninstall remove dependencies?

No. It removes only the named package. Run brew autoremove afterward to remove dependencies that nothing else needs. Use brew autoremove --dry-run to see the list first.

What’s the difference between brew uninstall and brew uninstall —zap?

--zap only applies to casks. Plain uninstall removes the app. --zap also removes files the cask lists as belonging to the app, such as preferences and caches in ~/Library. A reinstall after --zap starts with default settings.

I get “zsh: command not found: brew” when I try to uninstall

Homebrew is installed but not on your PATH. On Apple Silicon it lives in /opt/homebrew/bin. See how to fix “zsh: command not found: brew”.

Why is the package still there after brew uninstall?

Three common causes. You uninstalled a different formula with a similar name, like node instead of node@24. Several versions were installed, so add --force to remove all of them. Or the command comes from somewhere else on your PATH. Check with which -a <command>.

Is it safe to delete ~/Library/Caches/Homebrew?

Yes. It holds only downloaded bottles and source files. brew cleanup --prune=all is the cleaner way to empty it, because it also removes old versions and stale links in one step.