ClearDisk
Buy for $10Download ClearDiskDownload
A LITTLE MORE CLARITY

How to list installed Homebrew packages and their sizes on Mac

Run brew list in Terminal to see all installed formulae and casks, brew leaves --installed-on-request to see top-level packages you chose yourself, and du -h -d 1 "$(brew --cellar)" to measure disk space per package. To back up your entire setup before cleaning up, run brew bundle dump to write a Brewfile.

1. List formulae and casks

brew list with no arguments prints installed formulae and then installed casks: in columns in a Terminal window, one per line when the output goes to a file or another command. Formulae are command-line packages Homebrew keeps in its Cellar; casks are Mac apps and other prebuilt software. --formula and --cask print one kind only, and --versions adds the installed version numbers.

Give brew list a name and it describes that package instead: for a formula it summarises the files in its folder, and for a cask it lists what it installed, such as an app in Applications. brew list --pinned shows formulae you have pinned so brew upgrade leaves them alone.

brew list
brew list --formula
brew list --cask
brew list --versions
brew list node

2. Separate what you asked for from dependencies

Some formulae arrive as dependencies of other software. brew leaves lists installed formulae that no other installed formula or cask depends on; it does not identify everything you chose yourself. --installed-on-request narrows that to leaves you installed yourself, and --installed-as-dependency shows leaves that came in as a dependency but are no longer needed by anything.

brew list --installed-on-request answers a slightly different question: every formula you installed by name, including ones that other formulae also use. The short forms -r and -p work for leaves, but the long forms are easier to read back later. Leaves installed as dependencies are what brew autoremove targets; the cache cleanup guide covers that command.

brew leaves
brew leaves --installed-on-request
brew leaves --installed-as-dependency
brew list --installed-on-request

3. See why a formula is installed

brew deps --tree --installed draws a tree under each installed formula showing what it pulled in. It gets long on a busy Mac, so pass a name to see one package’s tree. The reverse question, what needs this formula, is brew uses --installed, which reports only installed formulae and casks.

Run brew uses before removing a formula that is not a leaf. brew uninstall refuses to remove something another installed formula or cask needs, and names what needs it. That refusal usually means the removal would break a tool you still use.

brew deps --tree --installed
brew deps --tree node
brew uses --installed openssl@3

4. Check package sizes without scanning the wrong folder

Start with brew info followed by a formula name, such as brew info node, for its installed versions and sizes. To measure every formula folder, paste the complete block below into macOS Terminal. It checks that Homebrew returned an existing folder before running du. Nothing is deleted.

The output has one row per immediate subdirectory and a final total for the Cellar. Those package rows are already included in the total, so do not add the total again. Rows are not sorted by size. An empty Cellar produces just its directory total. If du prints an access or read error, treat the result as incomplete; the command keeps the error visible and returns a failure status.

To inspect the Caskroom, replace --cellar with --caskroom in the same block. A missing Caskroom can mean no casks have been installed. Its size also excludes apps installed elsewhere, usually in Applications. These figures describe the folders du can read, not a guaranteed amount you can reclaim.

If you see “size scan skipped,” read any Homebrew error above it and check that brew works in this Terminal. The block refuses an empty path, the filesystem root or a missing directory. It avoids the wildcard that can scan unrelated folders when a path lookup fails. Do not add sudo or broaden permissions just to get a complete number.

Check brew uses --installed with the formula name before considering removal. Homebrew normally refuses to uninstall a formula another installed package needs. Cached downloads are separate from installed packages; use the cache guide linked below to inspect them.

(
  if cleardisk_brew_dir="$(brew --cellar)" &&
    [ -n "$cleardisk_brew_dir" ] &&
    [ "$cleardisk_brew_dir" != "/" ] &&
    [ -d "$cleardisk_brew_dir" ]; then
    du -h -d 1 "$cleardisk_brew_dir"
  else
    printf '%s\n' 'No valid Homebrew folder; size scan skipped.' >&2
    exit 1
  fi
)

5. Save the list as a Brewfile

brew bundle dump writes your taps, formulae and casks into a file called Brewfile, plus other supported entries, such as Mac App Store apps or VS Code extensions, when those tools are installed. Homebrew describes it as an installed-state snapshot: keep it in version control, compare two snapshots with diff, or use it to set up a new Mac. By default it includes a short description of each package.

Dump refuses to overwrite an existing Brewfile; add --force to replace it, or use --file=- to print the list in Terminal instead. brew bundle install with the same --file path installs everything in it again. brew bundle cleanup works the other way and removes what is not in the file, so read its list before adding --force.

brew bundle dump --file="$HOME/Brewfile"
brew bundle dump --file=-
brew bundle install --file="$HOME/Brewfile"

Common questions

How do I see which Homebrew packages I chose versus what came in as dependencies?

brew leaves lists formulae that no other installed formula or cask depends on, and --installed-on-request narrows those leaves to formulae you installed by name. Use brew list --installed-on-request to include packages you chose that other formulae also depend on.

How can I tell why a Homebrew formula is installed if I didn't choose it?

Run brew uses --installed on that formula to see what still depends on it, and check before removing anything that isn't a leaf, since brew uninstall will refuse and name what needs it.

How do I back up my list of Homebrew packages before a fresh Mac setup?

Run brew bundle dump to write your taps, formulae, and casks into a Brewfile, which Homebrew describes as an installed-state snapshot you can keep in version control or use to set up a new Mac.

Which Homebrew packages are taking up the most disk space?

Use brew info with a formula name for its installed size, or the guarded du block above for Cellar folder totals. Read errors mean a partial measurement. Caskroom size can miss apps installed elsewhere, usually /Applications. Folder size alone does not tell you whether a package is safe to remove.

References & further reading

These guides combine the linked official guidance with ClearDisk’s documented behavior. Your files and app settings determine the right next step.

Main guide: developer storage on Mac · Related pillar: clear Xcode Derived Data on Mac · Browse all Developer storage guides →

FROM A NUMBER TO AN ANSWER

See what’s using
your space.

Explore your Mac with ClearDisk’s free local scanner.
Review the files. Keep the control.

Download free scannermacOS 15+ · version 2.2.1Cleanup license: $10 once