# How to clear developer caches on your Mac

> Xcode, Homebrew, npm and Docker each have their own way to give space back, set out in their own documentation.

Checked against macOS 27 on 11 October 2026.

Developer tools keep downloads, caches and old versions so your next build or install is quick. Over time they can take a lot of space. Each tool below has its own way to clean up, and every step comes from that tool’s own documentation.

## Xcode

Xcode’s settings show how much space each platform, simulator runtime and optional component uses, and let you remove the ones you don’t need.

1. In Xcode, choose Xcode › Settings, then click Components in the sidebar.
2. Look through the three groups: Platform Support, the platforms you can build for; Other Components, optional Xcode features; and Other Installed Platforms, the simulator runtimes for different devices and OS releases.
3. Click the information button next to a component you no longer use.
4. In the dialog, click Delete or Turn Off.

Xcode shows how much storage you can recover from each component before you remove it.

Apple’s documentation doesn’t cover deleting Xcode’s derived data, device support files or archives, so this guide doesn’t either.

Source: Apple Developer Documentation, [Downloading and installing additional Xcode components](https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components).

## Homebrew

Homebrew already tidies up after itself. It removes old versions of a formula when you upgrade it with `brew upgrade`, and it does extra cleanup every 30 days.

To clean up now:

```sh
# See what would be removed, without removing anything
brew cleanup --dry-run

# Remove stale lock files, outdated downloads and old versions
brew cleanup
```

`brew cleanup` removes downloads more than 120 days old. You can change that age with the `HOMEBREW_CLEANUP_MAX_AGE_DAYS` environment variable.

To go further:

| Command | What it removes |
| --- | --- |
| `brew cleanup --prune=all` | Every file in the cache, whatever its age |
| `brew cleanup --scrub` | Downloads of even the latest versions, except downloads for the formulae and casks you have installed |

To see where Homebrew keeps its downloads, run `brew --cache`. It’s usually `~/Library/Caches/Homebrew`.

Source: Homebrew Documentation, [brew(1)](https://docs.brew.sh/Manpage) and [FAQ](https://docs.brew.sh/FAQ).

## npm

npm’s documentation says you rarely need to clear its cache. The cache repairs itself, and the only reason to clear it is to get disk space back. npm never removes data from the cache on its own, so the cache grows as you install packages. It lives in `~/.npm`.

To tidy the cache without emptying it:

```sh
npm cache verify
```

This checks the cache, removes data it no longer needs, and verifies what’s left.

To empty it completely:

```sh
npm cache clean --force
```

> [!NOTE]
> `npm cache clean` only runs with `--force`, because emptying the cache is rarely needed.

Source: npm Docs, [npm-cache](https://docs.npmjs.com/cli/v11/commands/npm-cache).

## Docker

Docker doesn’t remove containers, images or volumes unless you ask it to. Start by seeing what uses the space:

```sh
docker system df -v
```

Then remove what isn’t in use:

```sh
docker system prune
```

This removes stopped containers, unused networks, dangling images and unused build cache. It asks you to confirm first, and it keeps volumes and tagged images.

> [!IMPORTANT]
> Two options delete more. `--volumes` also removes unused anonymous volumes, which can hold data. `-a` also removes every image that no container uses, which you may need to download again. Check what you’re removing before you add either.

Docker Desktop keeps your containers and images in one disk image on your Mac. Deleting images frees space, but deleting files inside a running container doesn’t. The space can take a few minutes to come back to your Mac. To reclaim it straight away:

```sh
docker run --privileged --pid=host docker/desktop-reclaim-space
```

To see where the disk image is and how much space it really uses, open Docker Desktop and go to Settings › Resources › Advanced.

> [!IMPORTANT]
> Don’t move the disk image in the Finder, or Docker Desktop can lose track of it. Use Disk image location in the same settings instead. Lowering the disk image’s maximum size deletes it, along with every container and image inside.

Source: Docker Docs, [Prune unused Docker objects](https://docs.docker.com/engine/manage-resources/pruning/) and [FAQs for Docker Desktop for Mac](https://docs.docker.com/desktop/troubleshoot-and-support/faqs/macfaqs/).

## Sources

- Apple Developer Documentation: [Downloading and installing additional Xcode components](https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components)
- Homebrew Documentation: [brew(1)](https://docs.brew.sh/Manpage)
- Homebrew Documentation: [FAQ](https://docs.brew.sh/FAQ)
- npm Docs: [npm-cache](https://docs.npmjs.com/cli/v11/commands/npm-cache)
- Docker Docs: [Prune unused Docker objects](https://docs.docker.com/engine/manage-resources/pruning/)
- Docker Docs: [FAQs for Docker Desktop for Mac](https://docs.docker.com/desktop/troubleshoot-and-support/faqs/macfaqs/)

Every source was checked on 11 October 2026, against macOS 27.

---

Disk Census finds the caches and build files your developer tools leave behind, and marks which ones rebuild themselves and are safe to delete. [See how Disk Census works](https://diskcensus.com/)
