DEV Community

Hamid Haghdoost
Hamid Haghdoost

Posted on

How I Freed Up Tons of Storage on My Mac

My Mac was almost full. It said that “Documents” used 39 GB, but I didn’t know what was taking so much space. As a software developer, I have tools like npm, Docker, and Homebrew that keep files to work faster. These files can get very big. Here’s how I fixed it.


Step 1: Look at Documents

I checked my Documents folder in Finder, but the files there were much smaller than 39 GB. Then I used Terminal:

du -sh ~/Documents/* | sort -h
Enter fullscreen mode Exit fullscreen mode

This shows the size of each file and folder. Most were small. So the big files were hidden in caches and tools.


Step 2: Clear developer tool caches

  1. npm (Node.js)
du -sh ~/.npm
npm cache clean --force
Enter fullscreen mode Exit fullscreen mode

This freed 3.5 GB.

  1. Docker
docker system df
docker builder prune
Enter fullscreen mode Exit fullscreen mode

My Docker cache alone was 19 GB!

  1. Homebrew
du -sh ~/Library/Caches/Homebrew
brew cleanup
Enter fullscreen mode Exit fullscreen mode

This cleared hundreds of MBs.

  1. VSCode
rm -rf ~/Library/Application\ Support/Code/Cache/*
rm -rf ~/Library/Application\ Support/Code/CachedData/*
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage/*
Enter fullscreen mode Exit fullscreen mode

This freed about 5 GB.


Step 3: Remove old tools you don’t use

I had old versions of PHP and some apps I didn’t use. I removed them:

brew uninstall php@7.1 php@7.4 php@8.0
brew uninstall --cask fig
brew uninstall nginx
Enter fullscreen mode Exit fullscreen mode

Step 4: Check other caches

Other tools also store caches:

  • Python pip: ~/.cache/pip
  • Go modules: ~/go/pkg/mod/cache
  • iCloud: ~/Library/Mobile Documents

You can check their size with:

du -sh <folder>
Enter fullscreen mode Exit fullscreen mode

Step 5: Keep it clean

I now run these commands every few weeks:

npm cache clean --force
docker builder prune
brew cleanup
rm -rf ~/Library/Caches/*
Enter fullscreen mode Exit fullscreen mode

This keeps my Mac from filling up again.


Lessons learned

  • Most big storage is hidden in caches, not in Documents.
  • Tools like Docker, npm, Homebrew, and VSCode can use lots of GB.
  • Cleaning regularly can free 20–40 GB.
  • Terminal commands like du -sh and docker system df help find big files.

With these steps, my Mac now has plenty of space and runs better.

Top comments (0)