If you're a developer working on a Mac, you've probably seen the dreaded "Your disk is almost full" notification. Between Xcode's DerivedData, scattered node_modules folders, Docker images, and various package manager caches, developer tools can silently consume 50 to 500 GB of your disk space.
This guide covers every major cache and build artifact location on macOS, with exact commands to check sizes and clean them safely. Whether you're on a 256GB MacBook Air or a 1TB MacBook Pro, these steps will help you reclaim significant space.
Table of Contents
- Xcode DerivedData (10-80 GB)
- node_modules Folders (5-100 GB)
- Docker Images & Containers (10-50 GB)
- Homebrew Cache (1-10 GB)
- pip Cache (1-5 GB)
- CocoaPods Cache (1-10 GB)
- Rust/Cargo Target Dirs (5-50 GB)
- Gradle Cache (2-20 GB)
- Xcode Archives & Simulators (5-50 GB)
- Other Hidden Space Eaters
- The Automated Approach
1. Xcode DerivedData (10-80 GB)
Xcode stores build artifacts, indexes, and logs in the DerivedData folder. If you work on multiple projects or switch branches frequently, this folder grows quickly.
Check the size
du -sh ~/Library/Developer/Xcode/DerivedData
It's common to see 20-80 GB here, especially if you've been developing for a while.
Clean it
# Delete all DerivedData (safe -- Xcode rebuilds what it needs)
rm -rf ~/Library/Developer/Xcode/DerivedData/*
Also check Xcode caches
# Xcode cache folder
du -sh ~/Library/Caches/com.apple.dt.Xcode
# Clean it
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
2. node_modules Folders (5-100 GB)
node_modules is famously heavy. Each Node.js project has its own copy of all dependencies, and they add up fast. A single React project can have a 500MB+ node_modules folder.
Find all node_modules and their sizes
# Find all node_modules folders, sorted by size
find ~ -name "node_modules" -type d -prune 2>/dev/null | while read dir; do
echo "$(du -sh "$dir" 2>/dev/null | cut -f1)\t$dir"
done | sort -hr | head -20
Clean old project node_modules
# Delete node_modules from projects you haven't touched in 30+ days
find ~/Projects -name "node_modules" -type d -prune \
-newer <(date -v-30d +%Y%m%d) -exec rm -rf {} + 2>/dev/null
node_modules, you'll need to run npm install or yarn install in that project directory before building again.
Also clean the npm/yarn global cache:
# npm cache
du -sh ~/.npm
npm cache clean --force
# yarn cache
du -sh ~/Library/Caches/Yarn
yarn cache clean
# pnpm cache
du -sh ~/Library/pnpm/store
pnpm store prune
3. Docker Images & Containers (10-50 GB)
Docker Desktop for Mac stores images, containers, volumes, and build cache in a single disk image. This can grow to enormous sizes.
Check Docker disk usage
docker system df
Clean up Docker
# Remove unused images, containers, networks, and build cache
docker system prune -a
# Also remove unused volumes (be careful -- this deletes data)
docker system prune -a --volumes
The Docker Desktop VM disk image is located at:
du -sh ~/Library/Containers/com.docker.docker/Data/vms/
4. Homebrew Cache (1-10 GB)
Homebrew keeps downloaded packages and old versions in its cache directory.
# Check size
du -sh $(brew --cache)
# Clean all cached downloads
brew cleanup -s
# Remove all cached downloads (aggressive)
rm -rf $(brew --cache)/*
5. pip Cache (1-5 GB)
Python's pip stores downloaded packages in a cache directory.
# Check size
du -sh ~/Library/Caches/pip
# Clean pip cache
pip cache purge
# Or manually
rm -rf ~/Library/Caches/pip/*
If you use conda:
# Check conda package cache
du -sh ~/miniconda3/pkgs # or ~/anaconda3/pkgs
# Clean conda
conda clean --all
6. CocoaPods Cache (1-10 GB)
CocoaPods caches pod specs and downloaded pods.
# Check size
du -sh ~/Library/Caches/CocoaPods
# Clean cache
pod cache clean --all
# Also clean specs repo
rm -rf ~/.cocoapods/repos/trunk
7. Rust/Cargo Target Directories (5-50 GB)
Rust compilation artifacts are stored in target/ directories within each project. Debug builds are especially large.
# Find all Cargo target directories
find ~ -name "target" -type d -path "*/target" 2>/dev/null | while read dir; do
if [ -f "$dir/../Cargo.toml" ]; then
echo "$(du -sh "$dir" 2>/dev/null | cut -f1)\t$dir"
fi
done | sort -hr | head -20
# Clean a specific project's build artifacts
cd your-rust-project
cargo clean
# Cargo's global registry cache
du -sh ~/.cargo/registry
du -sh ~/.cargo/git
8. Gradle Cache (2-20 GB)
If you do Android development or use Gradle-based Java/Kotlin projects:
# Check Gradle cache size
du -sh ~/.gradle/caches
# Clean Gradle caches
rm -rf ~/.gradle/caches/*
# Android build caches
du -sh ~/.android/cache
rm -rf ~/.android/cache/*
9. Xcode Archives & Simulators (5-50 GB)
Xcode archives (from Product > Archive) and iOS Simulators can consume massive space.
# Check archives
du -sh ~/Library/Developer/Xcode/Archives
# Check iOS Simulator data
du -sh ~/Library/Developer/CoreSimulator
# Delete old simulators
xcrun simctl delete unavailable
# Delete ALL simulator data (aggressive)
rm -rf ~/Library/Developer/CoreSimulator/Devices/*
10. Other Hidden Space Eaters
Composer (PHP)
du -sh ~/.composer/cache
rm -rf ~/.composer/cache/*
Maven (Java)
du -sh ~/.m2/repository
# Be selective -- delete specific old versions
Go modules
du -sh ~/go/pkg/mod
go clean -modcache
Ruby gems
du -sh ~/.gem
gem cleanup
Swift Package Manager
du -sh ~/Library/Developer/Xcode/DerivedData/*/SourcePackages
du -sh ~/Library/org.swift.swiftpm
VS Code extensions cache
du -sh ~/.vscode/extensions
Trash
# Don't forget to empty the Trash!
du -sh ~/.Trash
# Empty it from terminal
rm -rf ~/.Trash/*
Quick Reference: All Locations
| Cache Type | Location | Typical Size |
|---|---|---|
| Xcode DerivedData | ~/Library/Developer/Xcode/DerivedData |
10-80 GB |
| node_modules | Each project directory | 5-100 GB total |
| Docker | ~/Library/Containers/com.docker.docker |
10-50 GB |
| Homebrew | $(brew --cache) |
1-10 GB |
| pip | ~/Library/Caches/pip |
1-5 GB |
| CocoaPods | ~/Library/Caches/CocoaPods |
1-10 GB |
| Cargo targets | */target/ in Rust projects |
5-50 GB |
| Gradle | ~/.gradle/caches |
2-20 GB |
| Xcode Archives | ~/Library/Developer/Xcode/Archives |
2-30 GB |
| iOS Simulators | ~/Library/Developer/CoreSimulator |
5-40 GB |
| Go modules | ~/go/pkg/mod |
1-10 GB |
| npm/yarn cache | ~/.npm / ~/Library/Caches/Yarn |
1-5 GB |
The Automated Approach
Running all these commands manually is tedious and error-prone. You need to remember paths, check sizes, and be careful not to delete the wrong things.
ClearDisk -- Clean All Caches Automatically
Free, open-source macOS menu bar app that finds and visualizes all your developer caches in one place. One-click cleanup for Xcode, npm, Docker, pip, CocoaPods, Cargo, Homebrew, and more.
Get ClearDisk (Free)ClearDisk is a free, open-source macOS menu bar app built with SwiftUI that handles all of the above automatically:
- Scans all cache locations -- Xcode DerivedData, node_modules, Docker, Homebrew, pip, CocoaPods, Cargo, SPM, and more
- Visual size breakdown -- See exactly how much space each cache type is using
- One-click cleanup -- Clean individual caches or everything at once
- Menu bar app -- Always accessible, lightweight, no main window needed
- Privacy-first -- No analytics, no telemetry, no network requests. Everything stays on your machine
Install via Homebrew
brew tap bysiber/cleardisk
brew install --cask cleardisk
Or download the latest .dmg from the releases page.
How Often Should You Clean?
It depends on your workflow, but here's a general guideline:
- Weekly: Check total disk usage. If it's getting tight, run a cleanup.
- Monthly: Clean Xcode DerivedData, old node_modules, and Docker unused images.
- Per project: After finishing a project or major milestone, clean its build artifacts.
- Before macOS updates: Free up space before installing major macOS updates (they need 20-40 GB free).
Summary
Developer caches are the #1 hidden space consumer on a developer's Mac. Between Xcode, npm, Docker, and other tools, it's common to have 50-200 GB of reclaimable space without even realizing it.
The key locations to monitor are:
~/Library/Developer/Xcode/DerivedData-- usually the biggest offender- Scattered
node_modulesfolders -- they add up fast across projects - Docker images and build cache -- grows silently in the background
- Package manager caches (Homebrew, pip, CocoaPods, Cargo)
Whether you clean manually with the commands above or use a tool like ClearDisk to automate it, regular cache maintenance keeps your Mac fast and your disk healthy.