Skip to content

Documents was 7.6 GB, and 6.2 GB of it was not documents

On a developer's Mac the Documents folder fills with code dependencies and build output. Measured: 7.6 GB, 208,906 files, 82 percent regenerable.

5 min read

Documents is where people keep projects, so it is where project tooling ends up. What System Settings calls Documents can be mostly things nobody wrote.

Inside DocumentsSizeRegenerable?
Build output (target, dist, build, .next)3.2 GBYes, by building again
node_modules, 12 folders2.4 GBYes, by installing again
.git history, 9 repositories0.6 GBOnly if pushed somewhere
Everything else1.4 GBThis is the actual work

6.2 GB of 7.6 GB, 82 percent, came back with one command per project. Two hundred thousand files is also why Finder, Spotlight and backups are slow on this folder.

Measure yours

cd ~/Documents
find . -type d -name node_modules -prune -exec du -sh {} + 2>/dev/null | sort -h | tail
find . -type d \( -name node_modules -prune \) -o -type d \( -name target -o -name dist -o -name build -o -name .next \) -prune -print0 2>/dev/null | xargs -0 du -sh 2>/dev/null | sort -h | tail
find . -type f | wc -l

The second command skips anything inside node_modules, because packages ship their own dist folders and counting both would count some bytes twice.

What to do

  • Old projects: delete node_modules and build output, keep the source. Archiving old projects covers doing it safely.
  • Repositories: a .git folder is only safe to lose if everything is pushed. git status and git log origin/main.. tell you.
  • iCloud: if Desktop and Documents sync to iCloud Drive, every node_modules file syncs too. Keep code outside Documents, or add .nosync to a folder name, as in iCloud Drive taking up space.

The per-project picture is in node_modules taking up space.

Common questions

Why is my Documents folder so big on a Mac?

On a developer's Mac, mostly dependencies and build output. On the Mac measured, 82 percent of 7.6 GB was node_modules, build folders and git history.

Is it safe to delete node_modules in Documents?

Yes. Each is rebuilt from the project's lockfile with npm install, pnpm install or yarn.

Should I keep code in the Documents folder?

Not if Documents syncs to iCloud Drive, because every dependency file syncs too. A folder such as ~/Developer avoids that.

How do I count the files in my Documents folder?

Run find ~/Documents -type f | wc -l in Terminal. The Mac measured had 208,906.

Read next