Skip to content

Repository files navigation

dotenv

official dotenv extension for vscode–from the creator of dotenv.

  • auto-cloaking
  • auto-completion
  • secret peeking
  • syntax highlighting
  • NEW: decryption peeking (for encrypted .env files)

Install from VS Marketplace

 

auto-cloaking

auto-cloaking demo

 

auto-completion

auto-completion demo

 

secret peeking

secret peeking demo

 

syntax highlighting

syntax highlighting demo

 

decryption peeking

decryption peeking demo

 

FAQ

Does it automatically cloak my secrets? Yes.

Open a .env file and its values start masked.

Click Toggle auto-cloaking at the top of the file or run Dotenv: Toggle auto-cloaking from the Command Palette to reveal or hide them.

Switching tabs hides them again in the Dotenv Editor.

 

Does it support .env variants? Yes.

.env, .env.example, .env.development, .env.staging, .env.production, other .env.* files, *.env, and .flaskenv are supported.

 

Can I autocomplete environment variables? Yes.

Start typing process.env. or your language's environment-variable expression.

Suggestions come from your dotenv files, with values masked and source filenames shown.

 

Can I reveal a value inside an autocomplete popup? Yes.

Open a suggestion's details and click Reveal value. Click Hide value to mask it again.

Only that source's value is revealed. The suggestion row stays masked, and your secret-peeking setting stays unchanged.

 

Can I peek at secrets without opening my .env file? Yes.

Hover over a reference such as process.env.SECRET_KEY or ENV["SECRET_KEY"].

The popup shows the source file and lets you Reveal value or Hide value. New hovers follow your dotenv.enableSecretpeeking setting.

 

Can I peek at encrypted values with dotenvx? Yes.

In the Dotenv Editor, hover over an encrypted: value and click Decrypt value. The file stays encrypted.

Click Hide value, leave the popup, or switch tabs to clear the displayed plaintext.

You'll need a saved file, a trusted workspace, and the dotenvx CLI installed locally. The CLI isn't bundled with this extension.

Install it using the dotenvx installation instructions.

dotenvx finds the matching private key through its usual lookup, such as .env.keys or its key store. A key stored only in GitHub Actions isn't available locally.

If dotenvx isn't on your PATH, set dotenv.dotenvxPath to its executable.

 

Does it highlight .env syntax? Yes.

Variable names, values, comments, and quoted strings have syntax highlighting. The Dotenv Editor also highlights numeric values.

 

Does it support languages other than JavaScript? Yes.

Auto-completion and secret peeking support JavaScript, TypeScript, Ruby, Python, PHP, Go, Java, .NET (C#, F#, Visual Basic), C/C++, Julia, Erlang, Perl, Swift, Clojure, Rust, Dart, Kotlin, and Elixir.

Values come from your dotenv files, rather than the running application's environment.

 

Does it support importing env from node:process? Yes.

Both node:process and process imports work, including named aliases and multiline imports.

import { env } from 'node:process'
console.log(env.SECRET_KEY)

import { env as environment } from 'node:process'
console.log(environment.SECRET_KEY)

 

Does it support .NET? Yes.

C#, F#, and Visual Basic support Environment.GetEnvironmentVariable, including System.Environment and the overload with an EnvironmentVariableTarget.

Type ( or " in the first argument, or request completion while typing a name. Hover over the name to peek at its value.

var secret = System.Environment.GetEnvironmentVariable("SECRET_KEY");

Values come from dotenv files. The extension doesn't read Windows registry values, appsettings.json, or IConfiguration.

 

Does it support C and C++? Yes.

Complete and hover over names in getenv calls. C++ also supports std::getenv and ::getenv.

const char *secret = getenv("SECRET_KEY");

 

Does it support Julia and Erlang? Yes.

Complete and hover over names in these expressions:

secret = ENV["SECRET_KEY"]
secret = get(ENV, "SECRET_KEY", "fallback")
Secret = os:getenv("SECRET_KEY").
Secret = os:getenv("SECRET_KEY", "fallback").

Erlang files need the erlang language mode provided by an Erlang extension. Fallback arguments aren't evaluated when a key is missing from your dotenv files.

 

Does it support Perl? Yes.

Suggestions preserve bare keys, single quotes, or double quotes. Hover over a name to peek at its value.

my $secret = $ENV{SECRET_KEY};
my $secret = $ENV{'SECRET_KEY'};
my $secret = $ENV{"SECRET_KEY"};

 

Does it support Swift and Clojure? Yes.

Complete names inside quotes and hover over them to peek at their values.

let secret = ProcessInfo.processInfo.environment["SECRET_KEY"]
let secret = getenv("SECRET_KEY")

Swift also supports Foundation.ProcessInfo.processInfo.environment, Darwin.getenv, and Glibc.getenv.

(System/getenv "SECRET_KEY")
(java.lang.System/getenv "SECRET_KEY")

 

Does it work with monorepos? Yes.

Completion and secret peeking look in the source file's directory and each parent directory up to its workspace root.

Sibling projects and other workspace folders stay separate. Your project doesn't need to install the dotenv package.

 

Can I see values from multiple .env files? Yes.

Each key appears once in completion, with its source filenames.

Hover and completion details show the values with their filenames, nearest directories first. The extension doesn't guess which environment your application runs.

Unsaved dotenv edits appear immediately in completion and secret peeking.

 

Can I use custom dotenv filenames? Yes.

Associate them with the dotenv language in your project's .vscode/settings.json:

{
  "files.associations": {
    ".dev.vars": "dotenv",
    "**/.env.d/*": "dotenv"
  }
}

This enables syntax highlighting, cloaking, and the toggle in the native editor, and includes those files in completion and secret-peeking discovery.

Open files with Dotenv selected as their language are included too.

 

Can I edit and copy values while they're cloaked? Yes.

Cloaking is visual: copied text contains the actual value.

The Dotenv Editor supports line numbers, multiple cursors, find/replace, folding, comments, and normal editing. Save, undo, and redo use the usual shortcuts and update the underlying document.

If another edit conflicts with yours, your draft stays available to copy instead of overwriting the other edit.

 

Does the Dotenv Editor prevent secrets from flashing when I switch tabs? Yes.

Values are masked before the editor becomes visible, and masking updates locally as you type. Each view starts masked and hides values again on tab switches.

The minimap and general hover previews are disabled; encrypted values have their own explicit Decrypt value action.

 

Does the Dotenv Editor follow my editor settings? Yes.

Fonts and basic editor settings follow VS Code. It uses Monaco, the editor component behind VS Code.

Custom theme token rules, arbitrary user keybindings, and other extensions don't automatically carry into the embedded editor.

 

Can I use the native VS Code text editor? Yes.

Choose Reopen Editor With → Text Editor.

Cloaking there uses temporary decorations, so values can briefly flash during file opens or tab switches.

The toggle is remembered in extension storage, and dotenv.enableAutocloaking controls cloaking in that view.

 

Does it preserve my syntax-color settings? Yes.

Cloaking no longer writes syntax-color settings.

On upgrade, the extension removes only the exact invisible TextMate rules inserted by older versions from editor.tokenColorCustomizations. Your other custom rules stay intact.

 

Can I cloak environment values in YAML? Yes.

In the normal YAML editor, values under env_variables, environment, and env are masked.

This includes Docker Compose maps and lists and Kubernetes name/value entries. Quotes and comments stay visible.

Values can briefly flash on file opens or tab switches. Invalid YAML is handled on a best-effort basis. YAML isn't a source for completion or secret peeking.

 

Can I customize which YAML sections are cloaked? Yes.

Set dotenv.yamlSections to replace the defaults, or use [] to disable YAML cloaking.

{
  "dotenv.yamlSections": ["env_variables", "environment", "env", "secrets"]
}

 

 

CHANGELOG

See CHANGELOG

 

Thank you for using dotenv-vscode.