If you're the kind of Mac user who spends a lot of time in Terminal and needs command-line tools like htop, wget, or node, you'll eventually want to install Homebrew, the package manager that makes installing them easy. And at some point — maybe when your disk fills up — you'll want to know how to uninstall Homebrew on Mac properly, too.
Here's how to do both, plus how to clean up the caches and leftovers Homebrew doesn't remove on its own.
What is Homebrew?
Homebrew is an open-source package management system that simplifies installing "home-brewed" software on macOS. That is, the large body of UNIX and open-source software available for download. It's written in Ruby and consists of a Git repository, which lets you download updated repositories from GitHub.
Homebrew downloads the files needed to install and run software, then compiles them into binaries for installation.
Why would I install Homebrew?
If you want to install UNIX tools that don't come with their own installers for macOS, Homebrew makes finding, creating, and configuring installation packages much easier than doing it manually.
How to install Homebrew
Homebrew uses the Command Line Tools to compile the source code into a working program tailored to your Mac. Before installing Homebrew, you’ll need to install the Command Line Tools first.
- Go to Applications > Utilities and launch Terminal.
- Type
xcode-select --installand press Return. - A pop-up window will tell you that xcode-select requires the command-line developer tools and ask for permission to install them. Click Install.
- Wait for the installation to finish.
Once Command Line Tools is installed, you can install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Type in your admin password to allow sudo access.
- You'll see a few lines explaining what the script will install and where. Press Return to continue.
- Wait for it to finish — this can take a while, depending on your Mac and internet connection. You'll see "Installation successful!" when it's done.
One more step if you're on an Apple silicon Mac: the installer ends with a short "Next steps" section asking you to add Homebrew to your PATH. Copy and run the two commands it shows. They add one line to your ~/.zprofile file. Skip this, and you'll get "brew: command not found" the next time you open Terminal.
To check that everything is working:
brew doctor
"Your system is ready to brew" means you're good to go.
Installing a package looks like this:
brew install [package name]
So, to install wget, for example:
brew install wget
If you need to install apps with a normal graphical interface — casks — use an extra flag:
brew install --cask firefox
Where Homebrew lives on Apple silicon vs. Intel Macs
Where Homebrew puts things depends on your Mac's chip, and plenty of older guides still hardcode the wrong path.
- Apple silicon (M1 to M4): everything lives under /opt/homebrew. Packages go in /opt/homebrew/Cellar, apps in /opt/homebrew/Caskroom.
- Intel: everything lives under /usr/local. Packages go in /usr/local/Cellar, apps in /usr/local/Caskroom.
You don't need to remember any of this. Homebrew can tell you where it is:
brew --prefix
brew --cellar
brew --caskroom
brew --cache
Every command later in this article uses these instead of hardcoded paths, so it works on any Mac.
How to uninstall a Homebrew package
You don't need to remove Homebrew to get rid of something you installed with it.
For a command-line tool (Homebrew calls these formulae), use this command:
brew uninstall wget
For an app (a cask):
brew uninstall --cask firefox
Homebrew automatically removes any dependencies it installed just for that package, as long as nothing else needs them.
If some of the dependencies are still there, check what’s using them:
brew uses --installed [package name]
Or look at the full dependency tree for a package:
brew deps --tree [package name]
To see only the packages you installed on purpose, without their dependencies:
brew leaves
And if brew autoremove keeps refusing to remove something, check whether you pinned it at some point and forgot:
brew list --pinned
Pinned packages are frozen: they won't upgrade, and their old versions will stay on your Mac. Unpin with brew unpin [package name].
How to clean up Homebrew without uninstalling it
Homebrew automatically clears old versions of each formula that is upgraded with brew upgrade, and performs additional cleanup every 30 days. However, if you’ve accumulated gigabytes of old versions and cached downloads, you might need to clean up sooner.
Here’s the list of cleanup commands you can use.
brew cleanup removes old versions of the packages you have installed and deletes cached downloads older than 120 days. Preview what it would remove first:
brew cleanup -n
To run the cleanup, use:
brew cleanup
If 120 days feels too long, shorten the window by adding a line to your shell config, for example, export HOMEBREW_CLEANUP_MAX_AGE_DAYS=30
brew cleanup -s clears more of the download cache, but still keeps the downloads for packages you currently have installed.
brew cleanup --prune=all deletes every cached download, whatever its age. Your installed packages won’t be touched, but if you ever want to roll back to an older version, Homebrew will have to download it again.
brew autoremove removes dependencies that are no longer needed. Recent Homebrew versions run this for you after uninstall and cleanup, but it's worth running by hand if you've turned that off or have an older setup.
brew doctor is a maintenance tool. It checks for configuration errors, missing dependencies, and other common setup problems.
To see how much space the download cache actually takes up, use:
du -sh $(brew --cache)
What brew cleanup doesn't touch
Homebrew only tidies what it created. It never looks inside your ~/Library folder, so anything an app made while it was running stays behind after you remove the app itself. Check these folders for any leftovers:
- ~/Library/Application Support/[app name]
- ~/Library/Preferences/[app name].plist
- ~/Library/Caches/[app name]
What Homebrew's cleanup misses
Two kinds of leftovers can still stay after you run brew cleanup and brew autoremove.
Orphaned casks
When you run brew uninstall --cask, Homebrew removes the app itself. It doesn't touch the settings, caches, and support files the app created while you used it. These can stay in your Library folder for years.
To check for leftovers after uninstalling any app:
ls ~/Library/Application\ Support | grep -i [app name]
ls ~/Library/Caches | grep -i [app name]
ls ~/Library/Preferences | grep -i [app name]
Anything listed here is safe to drag to the Trash. If you'd rather not dig through the Library by hand, CleanMyMac's Uninstaller (more on it below) finds these leftovers for you.
Leftover Cellar entries from interrupted installs
If an installation fails halfway, or you hit Control+C partway through, Homebrew can leave a half-empty folder in the Cellar that brew list doesn't know about. To find them, compare these two lists:
brew list --formula
ls $(brew --cellar)
Anything in the second list that isn't in the first is a leftover. brew cleanup catches some of these. For one that's left, run this command:
rm -rf $(brew --cellar)/[package name]
Double-check the name before you press Return.
How to uninstall Homebrew completely on Mac
To remove Homebrew itself, follow the official instructions:
- Open Terminal.
- Paste this command and press Return:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
The script lists everything it's about to delete and asks you to confirm. Type y and press Return. Enter your admin password if asked.
If you don't want to run a script downloaded from the internet without reading it first, download it, look through it, and then run it:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh -o uninstall.sh
less uninstall.sh
/bin/bash uninstall.sh
Run /bin/bash uninstall.sh --help to see the options, including --force to skip the confirmation prompt.
A few blind spots in this script:
- It leaves some folders behind. At the end, it prints a list under "The following possible Homebrew files were not deleted" and suggests you remove them yourself. Do that with
sudo rm -rf, one path at a time, checking each one. - On Apple silicon, it keeps your shell config. The
eval "$(/opt/homebrew/bin/brew shellenv)"line the installer added to~/.zprofileor~/.zshrcis still there. Delete it, or Terminal will complain the next time it opens. - Apps you installed as casks stay in your Applications folder. Remove them like any other app if you don't want them.
How to reinstall Homebrew from scratch
Wanting to remove and reinstall Homebrew is one of the most common reasons people uninstall it in the first place.
Once you uninstall Homebrew using the script above, check that nothing is left.
- On Mac with Apple silicon, use
ls /opt/homebrew - On an Intel-based Mac, run
ls /usr/local/Homebrew
If you see "No such file or directory", that’s good news, meaning all Homebrew directories were deleted.
Now, run the install command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The caches Homebrew never touches: npm, pip, and friends
Homebrew isn't the only package manager on a Mac used for development. npm, pip, Yarn, pnpm, Cargo, Go — each one keeps its own cache in its own place, and none of them clean up after each other.
On a Mac you’ve used for a while, these caches can easily reach several gigabytes each.
You can clear them one at a time:
brew cleanup -s
npm cache clean --force
pip cache purge
If you'd rather clear every developer cache across all your tools in one go, take a look at CleanMyMac CLI.
What to run after brew cleanup: CleanMyMac CLI
If you use your Mac for development, Homebrew is probably one of several package managers on it, and each one only cleans up after itself. CleanMyMac CLI solves that for you. It scans the caches of every developer tool it knows about — Homebrew, npm, Yarn, pnpm, pip, Poetry, uv, Cargo, Go, Docker, and more — in one pass, shows you what it found, and lets you clear it up.
Install it with Homebrew:
brew install --cask macpaw/taps/cleanmymac-cli
Then scan your developer caches:
cleanmymac clean dev
Nothing is deleted at this point. You get a list grouped by tool, with sizes, and you tick what you want to remove. After you confirm, it shows you exactly what went and how much space came back:
A few things worth knowing:
cleanmymacandcmmare the same command. Use whichever is quicker to type.cleanmymac purgefinds node_modules, .venv, target, and other build folders sitting inside your project directories, grouped by project. Anything newer than seven days is shown but left unchecked.cleanmymac ignore add [path]protects a folder so it never shows up in results.--forceskips the review step. Run without it first, so you know what it's going to remove.
CleanMyMac CLI is in public beta and needs macOS 11 or later. Check out the full command list on GitHub.
Prefer a visual tool? Use CleanMyMac's Uninstaller
If Terminal isn't your thing or you want to clear out leftovers from casks and other apps without going through ~/Library — CleanMyMac's Uninstaller makes this easy. It identifies all files associated with the app and removes them along with the application.
- Get your free CleanMyMac trial.
- Launch the app, click Applications in the sidebar, and run a scan.
- Click Manage My Applications.
- Check the box next to the app or apps you want to remove. Look under Leftovers for unneeded files belonging to apps you've already deleted.
- Click Uninstall.
Homebrew questions, answered
Can you remove Homebrew?
Yes. Run the official uninstall script from Homebrew's GitHub repository (the command is in the uninstall section above), then remove the leftover folders it lists at the end.
Can I delete the Homebrew cache on Mac?
Yes, and it's safe to do so. The cache is only downloads, so your installed software isn't affected. Run brew cleanup --prune=all or delete the folder directly with rm -rf $(brew --cache)
How do I remove Homebrew apps?
It depends on what you installed. For command-line tools, use brew uninstall [name]. Apps with a graphical interface are casks, so they need brew uninstall --cask [name]
How do I remove and reinstall Homebrew?
Uninstall with the official script, check that the Homebrew folder is gone, then run the install command again. Follow the instructions in the reinstallation section.
Is it safe to install Homebrew on my Mac?
Yes. Homebrew is open source, maintained by a large community, and used by millions of developers. The install script is public on GitHub, so you can read exactly what it does before you run it. Follow the installation steps at the top of this article.
Wrapping up
Homebrew is a very useful tool for anyone who wants to run open-source Unix software on their Mac without the hassle of installing it manually. You'll need to be comfortable with Terminal, but if you're the type of Mac user who's interested in these tools, that won't be a problem. And when it's time to clean up, remember that Homebrew only cleans up after itself. For everything else, from npm and pip caches to app leftovers, you've now got the commands to finish the job.