How to free up disk space on a developer Mac
"System Data: 180 GB" on a developer Mac is mostly rebuildable junk: dependency folders, build caches, simulators and Docker layers. Everything below can be regenerated, and the commands say what each one costs you.
Updated
See where the space went
df -h /
du -sh ~/Library/Developer ~/Library/Caches ~/.npm ~/.cache 2>/dev/null
du -sh ~/Library/Containers/com.docker.docker 2>/dev/null
Then the biggest folders in your home directory:
du -sh ~/* ~/.[!.]* 2>/dev/null | sort -h | tail -20
Work down the list below in order of size. Each item is rebuildable; the cost is a slower next build or a re-download.
node_modules in old projects
Every JavaScript project carries its own copy. Find them, with sizes, in your code folder:
find ~/code -name node_modules -type d -prune -exec du -sh {} + 2>/dev/null | sort -h
Change ~/code to wherever your projects live. Delete the ones for projects you aren’t working on:
rm -rf ~/code/old-project/node_modules
npm install (or pnpm install) brings them back. To do it interactively, npx npkill lists them and deletes with a keypress.
Xcode
Quit Xcode first. Then:
# Build output and indexes. Rebuilt on next build.
rm -rf ~/Library/Developer/Xcode/DerivedData
# Simulators for runtimes you no longer have installed.
xcrun simctl delete unavailable
# Simulator runtimes: list them, then delete old ones by identifier.
xcrun simctl runtime list
xcrun simctl runtime delete <identifier>
# Debug symbols for old iOS versions, re-created when you connect a device.
rm -rf ~/Library/Developer/Xcode/"iOS DeviceSupport"/*
# Simulator caches.
rm -rf ~/Library/Developer/CoreSimulator/Caches/*
Be careful with ~/Library/Developer/Xcode/Archives. Archives hold the debug symbols (dSYMs) for builds you shipped. Delete old ones from Xcode’s Window › Organizer only if you don’t need to symbolicate crash reports from those versions.
Docker
Check what Docker is holding first:
docker system df
Then remove what you don’t need, from least to most destructive:
docker builder prune # build cache
docker image prune -a # images not used by any container
docker container prune # stopped containers
docker system prune # stopped containers, unused networks, dangling images, build cache
docker volume prune # unused anonymous volumes
Volumes hold data. A database volume is your local database. docker volume prune only removes anonymous volumes by default; adding --all also removes unused named volumes, which is where most local databases live. Check docker volume ls before using it.
Docker Desktop stores everything in one disk image file:
ls -lsh ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
It’s a sparse file: the first number from ls -s is the space it actually uses, which can be much less than its listed size. Pruning should free host space within a short time, but if it doesn’t shrink, you can set a lower disk usage limit in Docker Desktop’s Settings › Resources, or use Troubleshoot › Clean / Purge data to reset it completely, which deletes all images, containers and volumes. Don’t delete or move Docker.raw by hand.
OrbStack and Colima keep their data in their own folders; use docker system prune the same way, or their own reset options.
Homebrew
brew cleanup -n # dry run: what would be removed
brew cleanup --prune=all # remove old versions and all cached downloads
Homebrew’s download cache lives at $(brew --cache). Check its size with du -sh "$(brew --cache)".
Package manager caches
npm cache clean --force # ~/.npm
pnpm store prune # removes packages no project references
yarn cache clean # Yarn 1
yarn cache clean --all # Yarn 2 and later
pip cache purge # Python
go clean -modcache # Go modules
pnpm’s store is shared between projects, so pruning it rarely hurts. npm and Yarn caches just mean the next install downloads again.
Other big ones worth checking: ~/.gradle/caches, ~/.cargo/registry, ~/.cache/huggingface and Ollama models in ~/.ollama/models (remove a model with ollama rm <name>).
~/Library/Caches
du -sh ~/Library/Caches/* 2>/dev/null | sort -h | tail -15
Quit the app that owns a folder, then delete that folder. Browsers, Spotify, Slack and JetBrains IDEs are usually the largest. Don’t delete ~/Library/Caches itself, and leave anything under /System alone.
Don’t forget
- Trash. Nothing is freed until you empty it.
- Time Machine local snapshots count as System Data.
tmutil listlocalsnapshots /lists them; macOS removes them automatically as space runs low. - Leftover processes. A dev server still running from a deleted folder can keep files open. Find orphaned ones in find orphaned node processes.
Doing this with Stat Space
Stat Space’s Disk tab has a “Free up space” scan for rebuildable developer data: Xcode DerivedData, device support, simulator caches, package manager caches, node_modules in projects unchanged for 30 days, and Docker build cache. It shows the size of each and deletes only what you confirm. A separate on-demand scan lists the largest folders in your home directory. Both are free, and nothing is scanned until you ask.
Questions
Is it safe to delete Xcode DerivedData?
Yes. It's build output and indexes. Xcode rebuilds it on the next build, which will be slower once. Quit Xcode first.
Why is System Data so large on my Mac?
System Data includes caches, developer folders under ~/Library/Developer, Docker's disk image, Time Machine local snapshots and swap. On a developer Mac, Xcode and Docker are usually most of it.
Is it safe to delete ~/Library/Caches?
Mostly. Apps rebuild their caches, and you'll get slower first launches and re-downloads. Quit apps first, and delete folders inside it rather than the folder itself.
Know what your Mac is doing, without adding to it.
Free, no account. Pro is $9.99 once for the first 100 buyers.