Every time you save a file, Spotlight silently indexes it — cataloguing metadata, content, and attributes so searches stay instant. Most of the time this is exactly what you want. But if you work with large build caches, package registries, or virtual-machine images, Spotlight can index tens of thousands of ephemeral files that you will never search for. Knowing how to exclude folders from Spotlight on Mac lets you trim that index, reduce background CPU and disk I/O, and reclaim real SSD space from a metadata store that can quietly grow into the gigabytes.
Why Spotlight Indexing Can Balloon Your SSD Usage
Spotlight's index lives primarily in /private/var/db/Spotlight-V100/ and a per-volume shadow at /.Spotlight-V100/. On a developer machine with active Xcode, Rust, or Maven builds, this index can exceed 10 GB because Spotlight re-indexes every intermediate object file, cached class, and dependency jar as soon as it appears. The indexing daemon mds (metadata server) and its worker mdworker also compete with your foreground work for CPU time and memory bandwidth during heavy build cycles.
Common offenders include:
~/Library/Developer/Xcode/DerivedData— compiled Xcode artifacts, sometimes 20–50 GB on its own~/.m2/repository— Maven's local repository; millions of tiny jar and pom files~/.cargo— Rust's registry and compiled cratesnode_modulesdirectories nested inside every JavaScript project~/Library/Caches— app caches that rotate constantly- Virtual machine bundles such as
.utmor.vmwarevmpackages
None of these are things you search for in Spotlight. Excluding them costs you nothing in usability and can meaningfully shrink your index and reduce thermal pressure.
How to Exclude a Folder From Spotlight: Step-by-Step
The built-in Privacy tab in System Settings is the safest and most permanent way to exclude folders. These steps apply to macOS Ventura, Sonoma, Sequoia, and the upcoming Tahoe release.
- Open System Settings (the gear icon in your Dock or Apple menu).
- Click Siri & Spotlight in the sidebar.
- Scroll down and click Spotlight Privacy….
- Click the + button at the bottom of the list, or drag a folder directly into the panel.
- Navigate to the folder you want to exclude (for example, select
DerivedDatainside~/Library/Developer/Xcode/) and click Choose. - Repeat for each folder. Changes take effect immediately —
mdsdrops those paths from the index and stops watching them.
You can also drag an entire drive or external volume into the Privacy list to exclude it wholesale — useful for NAS mounts or large external SSDs that hold media archives.
Terminal Method: Add Exclusions With mdutil and .metadata_never_index
For scripted setups or CI environments, two Terminal approaches give you programmatic control.
The .metadata_never_index sentinel file
Place an empty file named .metadata_never_index at the root of any folder and Spotlight will skip it without any System Settings interaction:
touch ~/Projects/my-rust-app/.metadata_never_index
This is especially useful inside project templates or dotfiles repos — commit the sentinel once and every clone is automatically ignored.
Disabling indexing on a volume with mdutil
To turn off Spotlight entirely for a mounted external volume, use mdutil:
sudo mdutil -i off /Volumes/ExternalDrive
To re-enable it later:
sudo mdutil -i on /Volumes/ExternalDrive
To check the current indexing state of any path:
mdutil -s /
Note: mdutil -i off on the boot volume requires disabling System Integrity Protection and is not recommended. Use the Privacy list for system-volume paths instead.
Which Developer Folders Are Worth Excluding
The table below summarises the highest-impact paths on a typical Apple Silicon Mac used for software development, their approximate index contribution, and how safe they are to exclude.
| Path | Typical size | Index contribution | Safe to exclude? |
|---|---|---|---|
~/Library/Developer/Xcode/DerivedData |
5–50 GB | Very high (millions of object files) | Yes — Xcode rebuilds on demand |
~/.m2/repository |
1–10 GB | High (many small jars) | Yes — Maven re-downloads as needed |
~/.cargo |
2–15 GB | High (compiled crate objects) | Yes — cargo re-fetches from registry |
~/Library/Caches |
1–20 GB | Medium-High (rotates frequently) | Yes — caches are ephemeral by design |
node_modules (per project) |
100 MB–2 GB each | Very high (hundreds of thousands of files) | Yes — npm/yarn reinstalls from package.json |
~/.gradle/caches |
500 MB–5 GB | Medium (jar and build caches) | Yes — Gradle re-populates on next build |
~/Library/Containers |
Varies widely | Low-Medium | Caution — contains sandboxed app data |
If you want to understand what is actually taking up space before deciding what to exclude, a tool like Crumb can audit all of these at once and show what is safe to remove before you delete anything. For a broader look at how these categories fit into your overall disk picture, see our guide on what is taking up space on your Mac.
How Much Space Can You Reclaim From the Spotlight Index Itself?
The Spotlight store files grow proportionally to the number of indexed items. On a machine with heavy development activity:
- The
/.Spotlight-V100/directory commonly ranges from 2–12 GB on well-used developer machines. - The
/private/var/db/Spotlight-V100/store adds another 500 MB–3 GB. - After exclusions are applied, macOS rebuilds the index in the background, typically completing within 30–60 minutes depending on the remaining file count.
You will not see these as free space immediately — macOS reclaims the blocks asynchronously as the trimmed index compacts. After the rebuild completes, run df -h / or check the Storage section of System Information to see the recovered space reflected.
Excluding Folders vs. Deleting Them: Key Differences
Exclusion tells mds to stop watching a folder; the folder and its contents remain untouched on disk. Deletion removes the files. These are complementary strategies, not alternatives:
- Exclude first to immediately stop new indexing and reduce CPU/IO pressure during active work.
- Delete cached content periodically — for example, clearing
~/Library/Developer/Xcode/DerivedDataor~/.m2/repositorywhen you know you are not mid-build — to reclaim the underlying SSD blocks. Exclusion alone does not free the space those files occupy.
For a deeper walkthrough of which caches are safe to clear and how much space each category typically holds, see our guide on what cache files on a Mac actually are.
Automating Exclusions for New Projects
If you constantly spin up new projects, manually adding each node_modules or target directory to System Settings becomes tedious. Two sustainable approaches:
Use .metadata_never_index in project templates
Add a .metadata_never_index file to your project scaffolding or dotfiles template. Any tool that generates new projects — Create React App, Cargo's cargo new, or your own shell function — can include this file so exclusion is automatic from day one.
Exclude the parent directory
Rather than chasing individual project folders, exclude a top-level parent. For example, if all your projects live under ~/Projects, excluding that single directory from Spotlight Privacy covers every subfolder automatically. You sacrifice Spotlight search inside those projects, but for code most developers rely on their editor's own search rather than Spotlight anyway.
Checking That Exclusions Are Working
After adding an exclusion, you can verify it is active from Terminal:
mdutil -s ~/Library/Developer/Xcode/DerivedData
If the exclusion is in effect, mdutil reports that indexing is disabled for that path. You can also watch mds activity drop in Activity Monitor — sort by CPU and look for mds and mdworker_shared processes that should calm down within a few minutes of adding heavily-indexed folders to the exclusion list.