How to Stop VS Code From Eating Your CPU Alive

🚀 A Practical Guide to Taming File Watchers, Git Scans, and Language Servers

Visual Studio Code is one of the most popular editors on the planet — but when it starts consuming CPU like it’s mining cryptocurrency, productivity tanks fast. The good news is that the problem usually isn’t VS Code itself. It’s the background processes running inside it.

In this guide, we’ll break down why VS Code spikes CPU, how to diagnose the issue, and the exact settings.json configuration that dramatically reduces CPU usage without breaking your workflow.


🔥 Why VS Code Uses So Much CPU

Most CPU spikes come from one of these:

1. File watchers scanning huge folders

VS Code tries to monitor every file in your project. That includes: - node_modules - vendor - dist / build - .git - log folders
These can contain tens of thousands of files — and VS Code tries to watch them all.

2. Git auto‑refresh scanning large repos

VS Code constantly checks for changes, even when nothing is happening.

3. Language servers indexing everything

TypeScript, JavaScript, PHP, Python — they all run background processes that can go wild.

4. Extensions running background tasks

Some extensions are lightweight. Others behave like full applications.

The fix is simple: tell VS Code what NOT to waste time on.


đź§  The Fix: A Smarter settings.json

VS Code has a hidden superpower: you can override its behavior with a single JSON file. By excluding heavy folders, calming down Git, and tuning language servers, you can cut CPU usage by 70–90% instantly.

Below is the best drop‑in configuration for anyone experiencing high CPU usage.


⚡ The Best VS Code settings.json for Performance

{
    // Reduce CPU from file watchers
    "files.watcherExclude": {
        "**/node_modules": true,
        "**/vendor": true,
        "**/dist": true,
        "**/build": true,
        "**/.git": true,
        "**/logs": true,
        "**/tmp": true,
        "**/.cache": true
    },

    // Prevent search from scanning heavy folders
    "search.exclude": {
        "**/node_modules": true,
        "**/vendor": true,
        "**/dist": true,
        "**/build": true,
        "**/.cache": true
    },

    // Reduce Git background scanning
    "git.autorefresh": false,
    "git.scanRepositories": false,

    // Calm down the TypeScript/JavaScript language server
    "typescript.tsserver.maxTsServerMemory": 2048,
    "typescript.tsserver.watchOptions": {
        "watchFile": "useFsEvents"
    },

    // Prevent PHP Intelephense from indexing giant files
    "intelephense.files.maxSize": 5000000,

    // Allow VS Code to open large files without freezing
    "files.maxMemoryForLargeFilesMB": 4096,

    // Optional: stop extensions from auto-updating in the background
    "extensions.autoCheckUpdates": false,
    "extensions.autoUpdate": false
}

đź§© What This Configuration Actually Does

1. Stops VS Code from watching massive folders

This is the biggest win. You still open files normally — VS Code just stops monitoring them in real time.

2. Prevents Git from constantly rescanning your repo

You still get diffs, commits, and branches. You just avoid the CPU spikes.

3. Tames the TypeScript server

Autocomplete and IntelliSense still work. The server just stops thrashing.

4. Keeps PHP Intelephense from choking on huge files

Normal PHP files still get full IntelliSense.

5. Makes large files open instantly

No more freezing when opening logs or minified bundles.

6. Stops extensions from updating in the background

You stay in control — and your editor stays stable.


🛠️ How to Open Your settings.json

The fastest way:

  1. Press Ctrl + Shift + P
  2. Type: Preferences: Open Settings (JSON)
  3. Hit Enter

Paste the optimized configuration, save, and enjoy the performance boost.


🎉 Final Thoughts

VS Code is powerful, but its defaults assume small projects. Modern development often involves massive folders, huge dependency trees, and language servers that never sleep.

A few smart tweaks in settings.json transform VS Code from a CPU hog into a smooth, responsive editor — even on large projects.

If your editor has been running hot, this configuration is the cleanest, safest, and most effective way to cool it down.