Reclaim gigabytes of developer junk on your Mac
If you write code on a Mac, the biggest space hogs are often not your files at all. Build products, dependency folders and caches pile up project after project, and none of them show up as one big item in Finder. The good news: almost all of it can be rebuilt, so it is safe to remove once you know what it is.
node_modules
Every JavaScript project carries its own copy of its dependencies, often several hundred megabytes. Old side projects you have not opened in months are the easiest win: the folder comes back with npm install when you need it.
find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h
Xcode: DerivedData, archives and simulators
- DerivedData (
~/Library/Developer/Xcode/DerivedData) holds build intermediates and indexes. Xcode recreates it on the next build; clearing it is also a classic fix for odd build errors. - Archives (
~/Library/Developer/Xcode/Archives) keep every build you archived. Keep the ones you shipped if you need their symbols for crash reports; old test archives can go. - Simulators for iOS versions you no longer have installed can be removed with:
xcrun simctl delete unavailable
Docker
Images, stopped containers and build cache grow quickly. See what is using space, then prune what is not in use:
docker system df
docker system prune
Add --volumes only if you are sure no volume holds data you need, such as a local database.
Package manager caches
- Homebrew:
brew cleanupremoves old versions and downloads. - npm, pnpm, Yarn: each keeps a download cache (
~/.npm, the pnpm store,~/Library/Caches/Yarn). - Gradle (
~/.gradle/caches) and CocoaPods (~/Library/Caches/CocoaPods) for mobile projects.
Caches only make the next install faster; removing them costs a re-download, nothing more.
Don't forget the Trash
Moving folders to the Trash does not free space until you empty it. That is a feature: if a build breaks after cleaning, you can put things back.
Where Sweep helps
Sweep for Mac, Windows and Linux finds these folders for you, shows how big each one is and when it was last used, and moves what you pick to the Trash rather than deleting it outright (for a few caches it runs the tool's own clean command instead, such as npm cache clean, and says so first). Its Ports view also lists dev servers still listening on ports such as 3000, so you can stop the one you forgot.