Claude Code JSON Parse Error: Unexpected EOF on Windows
Claude configuration file at C:\Users\<name>\.claude.json is corrupted: means the file ends before the JSON does: it is empty, or a save was cut off halfway. Close every Claude Code window, copy the newest good backup from .claude\backups over the file in PowerShell, and update to 2.1.319 or later. I reproduced the error on Claude Code 2.1.325 on Windows 11, tested the restore in PowerShell 7 and 5.1, then tried to break the file again with 123 hard kills and four rounds of 20 parallel writers. It did not break once.
The Short Answer
- Close every Claude Code session: terminals, VS Code windows, anything that runs
claude. - In PowerShell, run the line Claude Code printed after
You can manually restore it by running:. It is acpcommand, and it works in PowerShell. It does not work incmd.exe. The script further down does the same job and checks the backup first. - Run
claude --version. Below 2.1.319, runclaude update.
The restore brings back what the file held at the time of the backup: your account details, MCP servers and per-project state. Anything you changed after that backup is gone, so check your MCP servers with claude mcp list afterwards.
How I Tested This
Every run used Claude Code 2.1.325 on Windows 11, started from a stripped environment with a throwaway folder as USERPROFILE. No login, no API key and no model call. A claude -p without a login stops at Not logged in, but it reads .claude.json first, and that is all this error needs. The tests ran on 2026-11-16.
What the Error Means
Unexpected EOF is the JSON parser saying the text stopped early. I cut a valid 944-byte .claude.json down to its first 400 bytes and ran claude -p "hi" --safe-mode. This is the output, with my throwaway path shortened to C:\Users\you:
Claude configuration file at C:\Users\you\.claude.json is corrupted: JSON Parse error: Unexpected EOF
The corrupted file has been backed up to: C:\Users\you\.claude\backups\.claude.json.corrupted.1794816462902
A backup file exists at: C:\Users\you\.claude\backups\.claude.json.backup.1794816448017
You can manually restore it by running: cp "C:\Users\you\.claude\backups\.claude.json.backup.1794816448017" "C:\Users\you\.claude.json"
Configuration error in C:\Users\you\.claude.json: JSON Parse error: Unexpected EOF
The exit code was 1. Four more things I saw:
- An empty file gives the same error, as long as a backup exists. A 0-byte
.claude.jsonprinted the same error and the same restore advice. - An empty file with no backup does not. It printed
was empty and no backup holds anything:and carried on. The official changelog lists that change under 2.1.318.starting with defaults. claude doctordoes not get past it. The troubleshooting page says to runclaude doctorwhenclaudewill not start. Here it printed the same error and exited 1, and so didclaude mcp list. Onlyclaude --versionstill worked.- Claude Code leaves the broken file in place. The second run said
The corrupted file has already been backed up.and made no new copy.
Everything above is the non-interactive path. According to the error reference, an interactive session shows a recovery dialog instead. I did not open one.
What You Lose
From the docs, .claude.json holds your account details, MCP servers and per-project state. In practice that means:
- User and local scope MCP servers. I confirmed this one:
claude mcp add --scope useransweredFile modified:with the path of.claude.json. If you use MCP, this is the part that hurts. My MCP connection post covers what to check once they are back. - Per-project state, such as which folders you trusted.
- Account details. On Windows the login itself sits in a separate file,
%USERPROFILE%\.claude\.credentials.json, according to the authentication docs. The docs still say to sign in again if Claude Code asks.
Your settings.json files and a project's .mcp.json are separate files, so they survive.
Restore It in PowerShell
The printed cp line works because PowerShell treats cp as Copy-Item. I ran it as printed in PowerShell 7 and it restored the file. In cmd.exe, the same line failed with 'cp' is not recognized as an internal or external command. The error reference says the same: on Windows, run it in PowerShell. One small mismatch: the docs show cp -f, and 2.1.325 printed plain cp. Plain cp overwrote the file in my run.
I prefer a script that checks the backup before it trusts it. It picks the newest backup that is not empty and parses as JSON, keeps the broken file as .claude.json.broken, and copies the backup into place:
$cfg = "$env:USERPROFILE\.claude.json"
$good = Get-ChildItem "$env:USERPROFILE\.claude\backups\.claude.json.backup.*" |
Sort-Object Name -Descending |
Where-Object { $_.Length -gt 2 -and $(try { Get-Content $_.FullName -Raw | ConvertFrom-Json | Out-Null; $true } catch { $false }) } |
Select-Object -First 1
if (-not $good) { "No usable backup found"; return }
Copy-Item $cfg "$cfg.broken" -Force
Copy-Item $good.FullName $cfg -Force
"Restored $($good.Name)"
Paste it into a PowerShell window. I ran it in PowerShell 7.6 and Windows PowerShell 5.1, against a cut-off file with an empty decoy backup planted as the newest one. Both versions skipped the decoy, restored the real backup, and the next claude -p got past the config read to Not logged in. With no backup at all, it printed No usable backup found and changed nothing.
No usable backup? The docs suggest fixing the JSON in a .claude.json.corrupted.<timestamp> copy if one still has your setup. Failing that, rename .claude.json, start fresh and add your MCP servers again with claude mcp add.
How the Backups Work
Backups live in %USERPROFILE%\.claude\backups. Older reports, such as #26717, show them next to .claude.json in your home folder, so look in both places. On 2.1.325 I watched them for about seven minutes:
- One per minute at most. I added an MCP server every 62 seconds and got a new backup with each add. A first start followed by 20 parallel adds, all inside two seconds, left a single backup.
- Five kept. The sixth backup pushed the oldest one out. The docs say the same.
- A backup holds the file from before the save. The backup made during the add of
server-7listedserver-1toserver-6, notserver-7. - Claude Code points you at a good one. With an empty decoy as the newest backup, the printed
cpline skipped it and named the older real one. The changelog lists this fix under 2.1.318.
So a backup always trails the live file by at least one save. That is fine for most of what the file holds. If you added an MCP server just before the damage, check that it came back.
Want more like this?
New posts in your inbox, a few a month.
Why It Happens on Windows
Reported by users, not reproduced by me: GitHub issues #29004, #28813 and #26717 describe this error on Windows with two or more sessions open at the same time, on versions around 2.1.59 in February 2026. One reporter counted 315 .corrupted files in a week, arriving in bursts within the same second. All three issues are closed and locked, the first two as duplicates.
The official changelog points at a second cause. Its 2.1.319 entry reads: "Improved config saves on Windows: Claude Code waits longer for a file another program has open, so a kill during a save is less likely to leave ~/.claude.json empty". So another program holding the file open, combined with Claude Code being killed mid-save, could leave it empty. Closing a terminal window kills the process, which is one way that happens. Antivirus scanners, backup and sync tools are the usual programs that open files in your home folder. That last part is my reading, not a claim from the changelog.
I Tried to Break 2.1.325 and Could Not
The parallel-session race needs logged-in sessions, and I had no login to test with, so I did not reproduce it. What I could test was the save itself, with claude mcp add --scope user, which writes to .claude.json without a login:
- Parallel writers. Twenty
mcp addprocesses at once, four rounds. One round took 1.2 seconds. All 20 servers landed every time and the file stayed valid JSON. - Hard kills mid-save. 123 runs, each force-killed between 100 and 300 ms after start. 43 of them saved before the kill. The file parsed after every single run.
- Leftovers. After the kills I found a
.claude.json.lockfolder and a.claude.json.tmp.<pid>.<id>file. The next save cleared the lock and worked in 375 ms. The temp file suggests the new content is written beside the old file and swapped in at the end, which would explain why the kills never left a half-written config.
This does not prove the bug is gone. It shows that on 2.1.325 a killed save and 20 parallel CLI writers did not damage the file on my machine. Ten-session days with antivirus running are a different load.
How to Stop It Coming Back
- Update.
claude --versionprints something like2.1.325 (Claude Code). The Windows save fix is in 2.1.319 and the empty-file and restore-command fixes are in 2.1.318, per the changelog.claude updateinstalls the latest. - Exit sessions instead of closing the window. Type
/exit, so a save is not cut off by a killed process. This is the case the 2.1.319 note describes. - Keep the file out of other programs' hands. Do not sync
%USERPROFILE%\.claude.jsonwith a cloud folder, and do not keep it open in an editor while sessions run. - Keep your own copies. Five rotating backups can all be minutes apart, so keep daily ones too. The script below copies the file only when it parses, and keeps the newest 14.
$cfg = "$env:USERPROFILE\.claude.json"
$keep = "$env:USERPROFILE\claude-config-copies"
New-Item -ItemType Directory -Force $keep | Out-Null
try {
if ((Get-Item $cfg -ErrorAction Stop).Length -lt 3) { throw "empty" }
Get-Content $cfg -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop | Out-Null
Copy-Item $cfg "$keep\.claude.json.$(Get-Date -Format yyyyMMdd-HHmm)" -Force
Get-ChildItem "$keep\.claude.json.*" | Sort-Object Name -Descending | Select-Object -Skip 14 | Remove-Item
"Saved a copy"
} catch {
"Skipped: $cfg does not parse, nothing copied"
}
My first version had no size check, and it happily copied a 0-byte file: in both PowerShell versions, an empty file goes through ConvertFrom-Json without an error. The Length line fixes that. With it, the script copied a valid file, skipped a cut-off one and skipped an empty one, in PowerShell 7 and 5.1, and trimmed 17 copies down to 14. Run it once a day from Task Scheduler and a bad day costs you at most a day of changes. I tested the script by hand and did not register the task.
Why not let a machine do the boring part? One scheduled copy is cheaper than one lost afternoon of re-adding MCP servers.
What I Did Not Test
- Two or more logged-in sessions working at once, which is the case in the GitHub reports.
- The interactive recovery dialog.
- Versions before 2.1.325, so I cannot show the old behaviour next to the new one.
- Antivirus, OneDrive or other programs holding the file open.
FAQ
What does "JSON Parse error: Unexpected EOF" mean in Claude Code?
The file .claude.json in your user folder ends before the JSON does. It is empty or was cut off during a save. In my test on Claude Code 2.1.325, a file cut to 400 of its 944 bytes and an empty file with a backup present both produced this exact error, and claude -p exited with code 1.
How do I fix a corrupted .claude.json on Windows?
Close every Claude Code session, then copy the newest good backup from %USERPROFILE%\.claude\backups over %USERPROFILE%\.claude.json in PowerShell. The cp line Claude Code prints works in PowerShell but not in cmd.exe. Then run claude mcp list to see which MCP servers came back.
Does claude doctor fix the Unexpected EOF error?
No. In my test on 2.1.325, claude doctor printed the same corrupted-file error and exited with code 1. Restore a backup first, then run claude doctor if you still need it.
Will I lose my login or MCP servers?
You can lose MCP servers added with user or local scope, and per-project state, because they live in .claude.json. A backup holds the file from before its save, so changes after it are gone. On Windows the login itself is stored in .claude\.credentials.json, according to the docs, though Claude Code may still ask you to sign in again.
Is the .claude.json corruption fixed in recent versions?
The changelog lists an improved Windows config save in 2.1.319 and fixes for empty files and the printed restore command in 2.1.318. On 2.1.325 I could not corrupt the file with 123 hard kills or with four rounds of 20 parallel writers, but I did not test several logged-in sessions at once.
Related Articles
- Claude Code MCP Connection Closed on Windows: 4 causes
- Claude Code statusline on Windows: a setup that works
- Running Claude Code as an always-on agent on Windows
- XNDR services: AI agents and automation that run on Windows.
Liked this one? Get the next in your inbox.
New posts and the odd product note, a few emails a month. Easy to leave.