How to free up disk space on a developer Mac
On a developer Mac, most of the disk goes to files your tools can recreate: dependencies such as node_modules and Pods, build output such as build, .next and target, and shared caches from Xcode, Gradle, npm and Homebrew. Your source code is usually a tiny fraction of it. Reclaiming space safely means removing the recreatable files from projects you are not working on — and never the files that can't come back.
Where does the space go?
Developer disk usage falls into three groups:
- Per-project artifacts. Every project you clone carries its own dependencies and build output. A single JavaScript project's
node_modulesoften runs to hundreds of megabytes, and a Flutter or iOS project can hold several gigabytes of build files. Multiply by every repo you ever cloned. - Global tool caches. Xcode DerivedData, iOS device support files, simulators, the Gradle cache, the npm and pnpm stores, Homebrew downloads, CocoaPods and pip caches. These are shared by all projects and grow quietly.
- Everything else. Docker images and volumes, virtual machines, old Xcode versions, and downloads.
Check what is using space
Start with the numbers. du shows the size of a folder; sorting with sort -h puts the largest last. To see the biggest folders in your Developer folder:
du -sh ~/Developer/* 2>/dev/null | sort -h | tail -20And the usual global caches:
du -sh ~/Library/Developer/Xcode/DerivedData \
~/Library/Developer/Xcode/iOS\ DeviceSupport \
~/Library/Developer/CoreSimulator \
~/.gradle/caches ~/.npm ~/.pub-cache \
~/Library/Caches/Homebrew ~/Library/Caches/CocoaPods 2>/dev/nullClean per-project artifacts
Dependencies and build output are safe to remove from any project you are not actively working on: the next install or build recreates them. The usual commands, run inside a project:
| Stack | What to remove | How it comes back |
|---|---|---|
| Node / JavaScript | node_modules, .next, dist | npm ci or npm install, then build |
| Flutter / Dart | build, .dart_tool (or run flutter clean) | flutter pub get, then build |
| iOS / CocoaPods | Pods, build | pod install, then build |
| Android / Gradle | build, app/build, .gradle | The next Gradle build |
| Rust | target (or run cargo clean) | cargo build |
| Python | __pycache__, .venv | Recreate the venv, then pip install -r requirements.txt |
For a full list of which folders rebuild on their own and which need a reinstall, see which developer folders are safe to delete. If JavaScript is your main stack, find and delete every node_modules folder covers listing them by size across your whole disk.
Clear global caches
Each tool has its own cleanup command, which is safer than deleting its folders by hand:
- Xcode DerivedData: safe to delete; see is it safe to delete Xcode DerivedData?
- Simulators for runtimes you no longer have:
xcrun simctl delete unavailable - npm:
npm cache clean --force - pnpm:
pnpm store prune(removes packages no project references) - Yarn:
yarn cache clean - Homebrew:
brew cleanup -s(old versions and the download cache) - CocoaPods:
pod cache clean --all - Dart and Flutter:
dart pub cache clean(every project then re-downloads its packages) - pip:
pip cache purge - Docker: check with
docker system df, thendocker system prunefor stopped containers, unused networks and dangling images
Clearing a shared cache makes the next install or build slower, because everything is downloaded or compiled again. Clear caches when you need the space, not as a daily habit.
What never to delete
Source code, .env files, signing keys and keystores, provisioning profiles, and lockfiles such as package-lock.json, Podfile.lock or Cargo.lock. None of these can be regenerated exactly, and losing a keystore can mean you can no longer ship updates to an existing app. Be careful with ~/Library/Developer/Xcode/Archives too: archives hold the dSYMs you need to read crash reports for builds you shipped.
Make it a habit, not a weekend
The hard part is not the commands but finding which of dozens of projects are idle and how much each one holds. A quick monthly pass — list the biggest projects, clean the ones you have not opened in weeks, check the global caches — keeps the disk from filling up again. Moving folders to Trash instead of deleting them with rm -rf gives you a way back if you remove something you still needed.