Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Dotenv Safe EditNew to Visual Studio Code? Get it now.
Dotenv Safe Edit

Dotenv Safe Edit

Carbaz

|
1 install
| (0) | Free
Opens .env files in an isolated custom editor so their contents never become a readable text document, keeping them out of AI chat/agent context that reads open tabs.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Dotenv Safe Edit

Opens files matching *.env, *.env.*, .env, or .env.* in an isolated custom editor instead of the normal text editor.

Why

VS Code's normal text editor turns every open file into a TextDocument, which is exactly what tools like GitHub Copilot Chat's "Ask" mode read as implicit context (the active editor). If a .env file is left open and you switch to Ask mode, its contents can get pulled into the chat automatically.

Dotenv Safe Edit registers a non-text custom editor for .env files. The file is still read from disk to display it, but it never becomes a TextDocument and never shows up as an "active text editor" — so tools that read open tabs/editors have nothing to read while it's open here.

This does not protect against:

  • Agents/tools with direct filesystem or shell access (cat .env, file-read tools, etc.)
  • Anyone using "Open As... > Text Editor" to bypass Dotenv Safe Edit deliberately
  • Anything that indexes your workspace on disk directly (e.g. @workspace style search over files, if it bypasses editor state)

It closes one specific, real hole: forgetting to close the tab before switching to chat. Values are also masked by default to reduce the risk of shoulder surfing or accidental exposure when sharing your screen.

Features

  • Works for matching files anywhere on disk, including outside the current workspace folder.
  • Values masked by default (type="password" style inputs)
  • Per-row reveal/mask toggle, or reveal/mask all
  • Copy a single value to clipboard without revealing it on screen
  • Full editing inside the extension, so there's no need to open the .env file in a regular text editor
  • Add / edit / delete variables, saved directly to disk
  • Comments and blank lines are editable too (free-text lines, auto-prefixed with # unless left blank), not just read-only passthrough
  • Reorder any line (variable or comment/blank) via move up/down buttons or drag-and-drop using the handle on the left
  • Empty key or value fields are flagged with a red border
  • Sticky toolbar that stays visible while scrolling through long files
  • Save is disabled until there's an actual unsaved change
  • "Open as Plain Text..." escape hatch, with a confirmation warning before making the file contents visible in the normal editor
  • Bypass extension per-file: right-click the file → Open With... → Text Editor
  • Wrapping quotes (e.g. KEY="value") get baked into the displayed value.

Screenshots

Values masked by default

Dotenv Safe Edit with values masked

Values revealed for editing

Dotenv Safe Edit with values revealed

Install

Install Dotenv Safe Edit from the Visual Studio Marketplace, or directly from the VS Code Extensions view:

  1. Open the Extensions view in VS Code.
  2. Search for Dotenv Safe Edit.
  3. Select the extension and click Install.

Manual installation

To build and install the extension manually:

  1. npm install
  2. npm run package (runs tsc then vsce package)

Then install the extension:

  1. Right click the vscode-dotenv-safe-x.y.z.vsix file → Install Extension VSIX.

Or alternatively:

  1. VS Code → Extensions view → ... menu (top right) → Install from VSIX...
  2. Pick the generated vscode-dotenv-safe-x.y.z.vsix

Uninstall

  • Extensions view → Dotenv Safe Edit → gear icon → Uninstall
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft