Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Salesforce DotEnvNew to Visual Studio Code? Get it now.
Salesforce DotEnv

Salesforce DotEnv

Jonathan Gillespie

|
6 installs
| (0) | Free
| Sponsor
Editor companion for the sf dotenv CLI plugin - loads .env into VS Code, shows resolved values inline in sfdx-project.json, and squiggles missing replaceWithEnv references.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Salesforce DotEnv

Editor companion for the @jongpie/sf-dotenv-cli-plugin - loads environment variables from .env files inside VS Code and shows live values, missing-value squiggles, and inline .env context alongside replaceWithEnv entries in sfdx-project.json.

Features

  • Inline resolved values - CodeLens above each replaceWithEnv shows the current value (or a not-set indicator) from the loaded .env file
  • Hover for context - hover any replaceWithEnv value to see where it came from (.env file vs system environment) and copy just the value
  • Missing-value squiggles - undefined replaceWithEnv variables get red-underlined with a Quick Fix that adds them to your .env file
  • Duplicate-key warnings in .env files - since dotenv takes the last-defined value, duplicates are usually mistakes
  • One-click sf dotenv export - runs the CLI to scaffold a .env file from your existing replaceWithEnv entries, with confirmation before overwriting
  • .env file auto-reload - saves in .env reload variables into the extension host, terminal, and Salesforce Core settings without a window reload

Requirements

  • VS Code 1.137.0 or later
  • A Salesforce project - detected by the presence of sfdx-project.json in the workspace root
  • The sf CLI, with the @jongpie/sf-dotenv-cli-plugin installed. On first activation this extension will prompt you to install the CLI plugin if it isn't present; you can also run Salesforce DotEnv: Install CLI Plugin from the command palette

Usage

  1. Install this extension from the VS Code Marketplace
  2. Install the CLI plugin when prompted (or via the command palette)
  3. Create or open a .env file in your Salesforce project
  4. Open sfdx-project.json - replaceWithEnv values with missing variables get red-squiggled; hover any of them to see live values or add missing ones
  5. Click the status-bar item at the bottom-left to Reload, Select a different .env file, Export a new one, or Open Extension Settings

Companion to the sf dotenv CLI Plugin

The sf dotenv CLI plugin loads environment variables from a .env file before every sf command, so values referenced by replaceWithEnv in sfdx-project.json get substituted into your metadata during deploys.

This extension gives you the same visibility inside the editor. Once installed, it:

  • Loads the same .env file into VS Code's extension host and terminal, so integrated tooling sees the values without you exporting them in your shell
  • Shows the resolved value (or a "not set" warning) inline in sfdx-project.json next to every replaceWithEnv entry
  • Red-squiggles missing values with a quick-fix code action to add the variable to .env
  • Wraps sf dotenv export in a VS Code task with a confirmation prompt if the target file already exists

Commands

Command Description
Salesforce DotEnv: Load Environment Variables Force-reload the current .env file
Salesforce DotEnv: Select Environment File Pick a different .env file from those discovered in the workspace
Salesforce DotEnv: Salesforce DotEnv Menu Show the status-bar menu (Reload / Select / Export / Open Settings)
Salesforce DotEnv: Install CLI Plugin Install @jongpie/sf-dotenv-cli-plugin via the sf CLI
Salesforce DotEnv: Export Environment File Run sf dotenv export to create/update a .env file from sfdx-project.json
Salesforce DotEnv: Open Extension Settings Open VS Code settings scoped to this extension

Configuration

Setting Default Description
sf-dotenv.targetEnvFile .env Workspace-relative path to the .env file to load
sf-dotenv.envFilePatterns ["**/.env", "**/.env.*", "**/*.env"] Glob patterns used to discover .env files for the Select command
sf-dotenv.showInfoMessages true Show non-blocking info toasts when environment variables reload
sf-dotenv.showReplacementCodeLens true Show inline CodeLens above each replaceWithEnv entry with the resolved value or not-set indicator

How it works

  • The extension detects a Salesforce project by looking for sfdx-project.json in the workspace root
  • On activation and on every save of the target .env file, it re-parses the file with dotenv and updates the process env, terminal env, and Salesforce Core extension settings
  • Hovers, CodeLenses, and diagnostics on sfdx-project.json read from process.env, which is what the CLI plugin actually resolves against - so the editor's view matches the deploy-time view

Related projects

  • @jongpie/sf-dotenv-cli-plugin - the CLI plugin this extension pairs with

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft