How to export installed Homebrew packages to a Brewfile

A Brewfile records the package state that Homebrew Bundle can install or check later. Exporting the installed Homebrew set before replacing a computer, rebuilding a shell environment, or reviewing drift gives the package list a file path that can be diffed and committed.

brew bundle dump reads the active Homebrew installation and writes supported entries such as formulae, casks, taps, and app or plugin package types into the selected Brewfile. Writing to an explicit file keeps the export separate from a project Brewfile until the entries have been reviewed.

Use --force only when the destination Brewfile is meant to be replaced, because an existing file is overwritten. A compact export with --no-describe avoids generated description comments, and brew bundle check with --no-upgrade confirms that the exported entries are installed without turning the verification into an upgrade gate.

Steps to export installed Homebrew packages to a Brewfile:

  1. Choose the Brewfile path that should receive the export.

    Use a project path such as ./Brewfile for project dependencies and a home-directory path such as ~/Brewfile for a machine snapshot. Use --global only when writing Homebrew's configured global Brewfile path.

  2. Export the installed Homebrew entries to the Brewfile.
    $ brew bundle dump --file ~/Brewfile --force --no-describe

    --force overwrites an existing Brewfile at the selected path. Review the destination before running it in a directory that already has a curated project Brewfile.

  3. Inspect the exported Brewfile entries.
    $ cat ~/Brewfile
    tap "homebrew/core"
    brew "tree"

    Formulae, casks, and taps are the common entries. Homebrew can also record supported app, editor, and language ecosystem packages when the matching tools and entries are present.

  4. Edit out entries that should not be restored later.

    Open ~/Brewfile in your editor and keep packages that belong in the target workstation, project, or build image. Remove local experiments, one-off apps, and machine-specific extensions before sharing or committing the Brewfile.

  5. Check the exported Brewfile against the current Homebrew installation.
    $ brew bundle check --no-upgrade --file ~/Brewfile
    The Brewfile's dependencies are satisfied.

    --no-upgrade verifies that entries are installed without failing only because an installed package has a newer version available.
    Related: How to check a Brewfile with Homebrew Bundle