How to uninstall Terraform on Windows
Terraform is a single command-line program, so uninstalling it is quick, but the files that matter are elsewhere: your configurations, state files and each project's .terraform folder live in your project folders, and a token saved by terraform login lives in your profile. Keep your projects and back up the state of anything you still manage before you change the install. This guide covers Terraform installed per-user from the Hashicorp.Terraform winget package, which winget manages as a portable package.
Finish running commands first
Let any terraform plan or terraform apply finish, since stopping one halfway can leave a state lock behind. Terraform has no background process, tray icon or startup entry, so there is nothing else to quit.
Remove the app
A portable winget package has no separate uninstaller; winget removes it:
winget uninstall --id Hashicorp.Terraform
It also shows in Settings › Apps › Installed apps, where Uninstall does the same.
Where the data lives
| Location | What it holds | What to do |
|---|---|---|
%LOCALAPPDATA%\Microsoft\WinGet\Packages\Hashicorp.Terraform_Microsoft.Winget.Source_8wekyb3d8bbwe |
The terraform.exe program |
Removed by the uninstall |
%APPDATA%\terraform.d |
CLI data; terraform login saves its API tokens here in credentials.tfrc.json |
Keep it if you will reinstall; remove it to drop saved tokens |
Your project folders, with .terraform and .terraform.lock.hcl |
Configurations, providers and lock files for each project | Keep; they are yours, not the program's |
HashiCorp documents where the CLI keeps its configuration and credentials in its CLI configuration reference.
Check the result
Get-Command terraform -ErrorAction SilentlyContinue
winget list --id Hashicorp.Terraform
Test-Path "$env:LOCALAPPDATA\Microsoft\WinGet\Packages\Hashicorp.Terraform_Microsoft.Winget.Source_8wekyb3d8bbwe"
Test-Path "$env:APPDATA\terraform.d"
- If
Get-Commandsucceeds without suppressed errors, no output meansterraformis no longer on your PATH. A result means another copy is installed somewhere else; its path shows which one. - A completed
winget listquery with no match means the package record is gone. - The first
Test-PathreturningFalsemeans the package folder is gone;Truemeans files remain there. Test-Path "$env:APPDATA\terraform.d"returningTruemeans the CLI data folder, and any saved token, is still there, which is expected unless you removed it yourself.
If you installed it with winget
For portable packages, winget documents winget uninstall --purge, which also deletes everything inside the package folder, including files created there after the install. It does not touch %APPDATA%\terraform.d or your projects.
Account
Uninstalling does not revoke a token saved by terraform login. If you want it gone everywhere, revoke it in your HCP Terraform or Terraform Enterprise account settings as well as removing credentials.tfrc.json.
What Mole lists
For Terraform installed as a winget portable package:
- Mole removes the package through winget's own uninstall, which takes the package folder.
%APPDATA%\terraform.dis listed but not selected, since it can hold saved tokens.- Your project folders are never listed.
What this test covered
Tested on September 28, 2026 with Terraform 1.16.2 installed through winget as a portable package, per-user scope. %APPDATA%\terraform.d was ticked and removed in this test. Not verified: terraform login, a CLI configuration file, or a project with providers downloaded.
