ENV Highlighter
Syntax highlighting for .env files in VS Code. Keys, values, numbers, booleans, comments, and interpolations are each given distinct scopes so they color correctly in any theme.
Features
- Highlights env keys, values, numbers, booleans, and comments
- Supports quoted strings,
export, and ${VAR} interpolation
- Matches common env file patterns automatically
Supported tokens
| Token |
Example |
Scope |
| Key |
POSTGRES_USER |
keyword.other.env.key.dotenv |
= separator |
= |
punctuation.separator.key-value.dotenv |
| String value |
postgres |
string.unquoted.value.dotenv |
| Quoted string |
"hello world" |
string.quoted.double.dotenv |
| Number |
3600 |
constant.numeric.dotenv |
| Boolean |
true / false |
constant.language.boolean.dotenv |
| Comment |
# comment |
comment.line.number-sign.dotenv |
| Export keyword |
export |
keyword.other.export.dotenv |
| Interpolation |
${VAR} |
variable.other.interpolated.dotenv |
File matching
Automatically applies to:
.env
.env.local, .env.production, .env.development, etc.
any_name.env
Installation
From the Marketplace (recommended)
- Open VS Code.
- Go to Extensions (
Ctrl+Shift+X / Cmd+Shift+X).
- Search for ENV Highlighter.
- Click Install.
Or install from the command line:
code --install-extension env-highlighter.env-highlighter
Manual install
- Download or clone this repo.
- Copy the folder to your VS Code extensions directory:
- Windows:
%USERPROFILE%\.vscode\extensions\
- macOS/Linux:
~/.vscode/extensions/
- Restart VS Code.
Install from VSIX
code --install-extension env-highlighter-1.0.0.vsix
Customization
You can override colors in your settings.json:
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.other.env.key.dotenv",
"settings": { "foreground": "#C586C0" }
},
{
"scope": "string.unquoted.value.dotenv",
"settings": { "foreground": "#CE9178" }
}
]
}
}
Development
# Package the extension
npx @vscode/vsce package
# Publish (requires marketplace publisher + PAT)
npx @vscode/vsce publish
Open this folder in VS Code and press F5 to launch an Extension Development Host for local testing.
License
MIT