.env File Validator
Paste a .env file to find syntax errors, duplicate keys and values that break in shells or Docker, and compare it with .env.example to catch missing variables.
Last updated
.env
.env.example
Problems
0 errors4 warnings2 notes- missingIn .env.example but not in .env:
SENTRY_DSN - line 3warningSpaces around = in PORT. dotenv trims them, but sourcing the file in a shell fails.
- line 6infoPUBLIC_URL refers to $BASE_URL, which isn't defined in this file (it must come from the environment).
- line 7warningAPP_NAME contains spaces but isn't quoted. Quote it so shells and Docker read the same value.
- line 10warningPORT is already defined on line 3. dotenv uses the later value; some tools keep the first. Remove one.
- line 11warning"feature.search" contains . or -, which dotenv allows but shells and most platforms don't.
- line 11infofeature.search isn't UPPER_SNAKE_CASE, the usual convention for environment variables.
- extraIn .env but not documented in .env.example:
PUBLIC_URLAPP_NAMELOG_LEVELfeature.search
Parsed variables (10)
| 2 | NODE_ENV | pr••••••on |
|---|---|---|
| 3 | PORT | •••• |
| 4 | DATABASE_URL | po••••••••••••pp |
| 5 | REDIS_URL | re••••••••••••79 |
| 6 | PUBLIC_URL | ${•••••••••••pp |
| 7 | APP_NAME | De•••••••PI |
| 8 | JWT_SECRET | a-••••••••••••ng |
| 9 | LOG_LEVEL | •••• |
| 10 | PORT | •••• |
| 11 | feature.search | •••• |
.env.example
NODE_ENV= PORT= DATABASE_URL= REDIS_URL= PUBLIC_URL= APP_NAME= JWT_SECRET= LOG_LEVEL= feature.search=
Commit .env.example, never .env. It documents which variables exist without exposing any values.
Keyboard shortcuts:Ctrl ↵Copy .env.exampleCtrl SDownload .env.exampleCtrl KSearch tools
How to use the .env File Validator
Paste your .env
Values are masked on screen by default, so you can paste a real file without shoulder-surfing worries.
Add .env.example
Optionally paste your .env.example to find variables you forgot to set.
Fix the problems
Each problem shows its line number, how serious it is and how to fix it.
Generate .env.example
Copy or download a .env.example with every key and no values, ready to commit.
Features
- Parses like dotenv: export, comments, single, double and backtick quotes, multi-line values and inline # comments
- Errors for invalid names, lines that aren't KEY=VALUE and unclosed quotes
- Warnings for duplicates, spaces around =, unquoted spaces, trailing whitespace and KEY: value syntax
- Compares with .env.example to list missing and undocumented variables
- Flags ${VAR} references to variables that aren't defined in the file
- Detects well-known credentials: AWS access keys, live Stripe keys, GitHub and Slack tokens, private keys
- Masks values by default, with a Show values switch
- Generates a .env.example with every key and no values
Privacy
Your .env file is parsed by JavaScript in your browser tab and never uploaded or stored. Values are masked on screen unless you switch on Show values.
Examples
Spot problems in a .env
Spaces around =, an unquoted value with spaces and a duplicate key.
.env
NODE_ENV=production PORT = 8080 APP_NAME=Sensor Gateway API_URL=https://api.example.com PORT=3000Problems
Line 2 [warning] Spaces around = in PORT. dotenv trims them, but sourcing the file in a shell fails. Line 3 [warning] APP_NAME contains spaces but isn't quoted. Quote it so shells and Docker read the same value. Line 5 [warning] PORT is already defined on line 2. dotenv uses the later value; some tools keep the first. Remove one.Compare with .env.example
Two variables from .env.example were never set.
.env · .env.example
DATABASE_URL=postgres://app@db:5432/app REDIS_URL=redis://cache:6379 --- DATABASE_URL= REDIS_URL= JWT_SECRET= SENTRY_DSN=Problems
Missing from .env: JWT_SECRET, SENTRY_DSNReferences and multi-line values
${CDN_HOST} isn't defined in the file, and the key spans several lines.
.env
BASE_URL=https://example.com CALLBACK_URL=${BASE_URL}/auth/callback ASSETS_URL=${CDN_HOST}/static TLS_KEY="-----BEGIN PRIVATE KEY----- MIIEvQIBADANBg… -----END PRIVATE KEY-----"Problems
Line 3 [info] ASSETS_URL refers to $CDN_HOST, which isn't defined in this file (it must come from the environment). Line 4 [info] TLS_KEY spans lines 4–6 (multi-line value). Line 4 [warning] TLS_KEY looks like a private key. Never commit this file, and rotate the credential if it was shared.
Understanding .env files
.env syntax
# Comments start with #
NODE_ENV=production
export PORT=8080
APP_NAME="DevNest API" # quote values with spaces
GREETING='Hello $USER' # single quotes: no expansion
PRIVATE_KEY="-----BEGIN KEY-----
...
-----END KEY-----"Names should use letters, digits and underscores and not start with a digit; UPPER_SNAKE_CASE is the convention. Quote any value that contains spaces or #.
dotenv vs shells vs Docker
The same file is often read by several tools, and they don't agree on the details. dotenv libraries trim spaces around = and accept KEY: value, but source .env in a shell fails on both. Shells and most platforms reject names containing . or -. Duplicate keys resolve differently too. The validator flags anything that only works in some of them.
Keep secrets out of git
- Add
.envto.gitignorebefore the first commit. - Commit
.env.examplewith every key and no values, so new developers know what to set. - If a real secret was ever committed, rotate it — deleting the file doesn't remove it from git history.
- In production, prefer your platform's secret manager over a .env file on disk.
Frequently asked questions
Is it safe to paste a real .env file?
The file is processed only in your browser and nothing is sent or saved, and values are masked on screen by default. For extra safety, paste a copy with production secrets replaced.
Are spaces around the equals sign allowed?
dotenv libraries accept them, but shells don't: KEY = value makes source .env run a command called KEY. Write KEY=value to work everywhere.
What happens with duplicate keys?
Tools disagree: dotenv's parser keeps the later value, while some loaders keep the first. Keep each key once so every tool reads the same value.
Do I need quotes around values?
Only when a value contains spaces, a # or special characters, or spans several lines. Double quotes support escapes like \n; single quotes keep the text exactly as written.
What is .env.example for?
It lists every variable your app needs, without values, and is committed to git. New developers copy it to .env and fill it in, and this tool can compare the two to find missing keys.