Use ProductEnv in VS Code
The ProductEnv extension for VS Code shows, as you read code, which environments define each environment variable it uses, and warns about keys defined nowhere. It shows key names only: values are fetched only when you pull a file or copy one value.
Updated
- Install ProductEnv from the Visual Studio Marketplace (VS Code 1.82 or newer).
- Link your project folder with
npx productenv initif it has no.productenv.jsonyet: the extension starts in folders that have one. - Run ProductEnv: Sign in, which runs
productenv loginin a terminal. The extension uses that CLI login.
No CLI login? ProductEnv: Use service token stores a service token in VS Code's secret storage for that project. It reads only the token's environment and takes priority over the CLI login; Clear service token removes it.
- Hover an environment variable read in JavaScript, TypeScript, Python, Ruby, Dart, C#, Java, Kotlin, Go or PHP, or a key in a .env file, to see which environments define it, which are protected, and its schema type and description.
- Warnings for keys your code reads that no environment defines, and notes for required keys missing from an environment.
- The Environments view in the ProductEnv activity bar lists each environment's keys, values masked.
- Key lists are cached for 5 minutes; Refresh reloads them.
| Command | What it does |
|---|---|
| Pull .env | Writes .env, .env.local, .env.<environment> or a file you choose, and warns when git doesn't ignore it |
| Generate .env.example | Saves key names, placeholders and comments, never values |
| Copy value | Copies one value after you confirm |
| Validate required keys | Lists the required keys each environment is missing |
| Open in dashboard | Opens the linked environment in the dashboard |
| Refresh | Reloads the keys |
| Sign in / Use service token / Clear service token | Manage how the extension signs in |
| Open settings | Opens the extension's settings |
{
// Empty: the CLI login's API, else https://api.product-env.com
"productenv.apiUrl": "",
"productenv.webUrl": "",
"productenv.cliCommand": "productenv",
"productenv.diagnostics.enabled": true,
"productenv.diagnostics.ignoredKeys": ["NODE_ENV"],
"productenv.telemetry.enabled": false
}Usage statistics are off unless you turn on productenv.telemetry.enabled. They never include keys, values, file contents or tokens, and PRODUCTENV_TELEMETRY=0 or DO_NOT_TRACK=1 turn them off everywhere.