.env File Validator
Paste a .env, and optionally .env.example, to see problems line by line, then convert to docker-compose, Kubernetes ConfigMap and Secret, or GitHub Actions secret names. Everything runs in your browser and every value is masked in the results.
Updated
.env check
2 errors, 6 warnings
9 variables parsed with dotenv's rules
- Fail · Warning · line 4 · APP_NAMEThe value has spaces and is not in quotes. dotenv keeps it, but a shell running `source .env` splits it into words and fails. Wrap it in double quotes.
- Fail · Warning · line 7 · DB_URLLooks like a real secret (the value looks like a URL with a password in it). It is hidden here. Keep .env out of git (.gitignore), list only the name in .env.example, and rotate it if it was ever committed.
- Fail · Warning · line 8 · RAZORPAY_KEY_SECRETLooks like a real secret (the name looks like a secret and the value is not a placeholder). It is hidden here. Keep .env out of git (.gitignore), list only the name in .env.example, and rotate it if it was ever committed.
- Fail · Warning · line 10 · PORTDefined 2 times (lines 3, 10). dotenv keeps the last one, so the earlier line has no effect.
- Fail · Warning · line 11 · my-feature.flagThe name is valid for dotenv, but a shell, `source .env` and most process environments allow only letters, digits and underscore, and not a leading digit (POSIX "Name"). It contains . or -. Rename it, for example MY_FEATURE_FLAG.
- Fail · Error · line 12dotenv ignores this line because it is not NAME=value, a comment or blank. A missing = or a stray quote is the usual cause.
- Fail · ErrorMissing from .env but listed in .env.example: REDIS_URL.
- Fail · WarningIn .env but not in .env.example: APP_NAME, DEBUG, SENTRY_DSN, my-feature.flag. Add the names to the example so the next developer knows they exist.
docker-compose environment
services:
app:
environment:
NODE_ENV: ${NODE_ENV}
PORT: ${PORT}
APP_NAME: ${APP_NAME}
DEBUG: ${DEBUG}
DB_HOST: ${DB_HOST}
DB_URL: ${DB_URL}
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET}
SENTRY_DSN: ${SENTRY_DSN}
# my-feature.flag: rename it first (Compose interpolation needs letters, digits and underscore)
# "${NAME}" lets Compose fill the value from your shell or a .env file next to compose.yaml, so no secret is written into this file.- Variables parsed
- 9 unique (10 lines with a value)
- Likely real secrets
- 2 (hidden)
- Compared with .env.example
- 1 missing, 4 extra6 names in the example
| Line | Name | Value | Flags |
|---|---|---|---|
| 2 | NODE_ENV | •••••• | ok |
| 10 | PORT | •••••• | duplicate |
| 4 | APP_NAME | •••••• | ok |
| 5 | DEBUG | •••••• | export |
| 6 | DB_HOST | •••••• | ok |
| 7 | DB_URL | •••••• | secret |
| 8 | RAZORPAY_KEY_SECRET | •••••• | secret |
| 9 | SENTRY_DSN | (empty) | empty |
| 11 | my-feature.flag | •••••• | name |
- Everything here runs in your browser. The file is not uploaded, and no value is printed in the results: values are masked, and anything that looks secret stays masked even when you choose to show the rest.
- Line 5: DEBUG has an export prefix. dotenv and shells accept it; some other loaders do not.
- Line 9: SENTRY_DSN is empty. dotenv reads KEY= as an empty string, which is not the same as the variable being unset.
- The secret check is a heuristic on names and value shapes, not a scanner. It will miss secrets with unusual names, and may flag a harmless one. Use a real scanner such as your Git host's secret scanning before you push.
How does this check a .env file?
The file is parsed with the same line grammar as dotenv's lib/main.js: an optional export, a name of letters, digits, underscore, dot or hyphen, then = (or a colon and a space), then a value that may be in single quotes, double quotes or backticks. An unquoted value ends at a #, whitespace at both ends is trimmed, double-quoted values turn \n into a new line, quoted values can span lines, and when a name appears twice the last one wins. dotenv silently skips any line that does not fit, so this page lists those lines for you.
Then it checks what dotenv itself does not mind. Names that a shell, Docker or CI system would reject (the POSIX "Name" rule allows only letters, digits and underscore, with no leading digit), unquoted values with spaces, a # that cuts a value short, spaces around the =, duplicates, empty values, and ${VAR} references. References follow dotenv-expand's documented syntax, ${VAR}, $VAR, ${VAR:-default} and ${VAR:+alternate}, resolved from the variables in the file; undefined and circular ones are reported. A web page cannot see your process environment, which dotenv-expand also reads.
If you paste a .env.example too, it lists names missing from your .env, names in .env that the example does not know, and any real-looking secret in the example. Secret detection is a heuristic on key names (SECRET, TOKEN, PASSWORD, API_KEY, names ending in _KEY) and on value shapes such as private keys, JWTs and passwords inside URLs. Nothing is uploaded, and no value is ever printed: all values are masked by default, and a value that looks secret stays masked even if you choose to show the rest. The conversions give a docker-compose environment block, a Kubernetes ConfigMap and Secret, or a list of names for GitHub Actions, with no secret values in them.
line = [export ]NAME(=|: )value [# comment] NAME = [\w.-]+ (dotenv)
shell-safe NAME = [A-Za-z_][A-Za-z0-9_]* (POSIX "Name")
expansion: ${VAR} $VAR ${VAR:-default} ${VAR:+alternate} (dotenv-expand)
conversion: secret-looking names → Secret / secrets list; the rest → ConfigMap / environmentWhich .env mistakes does this find, and what does dotenv do with them?
| Problem | dotenv does | Reported as |
|---|---|---|
| Line with no = | Ignores it silently | Error with the line number |
| Same name twice | Keeps the last value | Warning listing the lines |
| Unquoted value with spaces | Keeps it, trimmed | Warning: a shell would split it |
| Unquoted # inside a value | Treats it as a comment and cuts the value | Warning |
| Quote not closed or text after it | Keeps the quote characters in the value | Error |
| KEY= | Empty string (not unset) | Note |
| Name with . or - or leading digit | Accepts it | Warning: not a valid shell or Actions name |
| ${VAR} not defined in the file | dotenv-expand also checks process.env | Warning |
| Name in .env.example but not in .env | Nothing | Error |
| Real-looking secret value | Loads it | Warning (error in .env.example); value never shown |
How to validate a .env file
- 1Paste the filePaste your .env in the first box. Use a copy with real secrets swapped for fake ones if you can; nothing leaves your browser either way.
- 2Add the example (optional)Paste .env.example in the second box to see missing and extra names, and to catch a real secret that was committed in it.
- 3Read the findingsFix errors first (ignored lines, unclosed quotes, missing names), then warnings. Each one gives the line number and the name, never the value.
- 4Convert if you need itPick docker-compose, Kubernetes or GitHub Actions to get the matching file with names only. Put the real values in your secret store or the dashboard.
Frequently asked questions
Is it safe to paste my .env into this page?
Why does my value get cut off at a # sign?
Does an empty value mean the variable is unset?
Why does a line with spaces in the value work in dotenv but break in my shell?
How does ${VAR} expansion work in a .env file?
What should go in .env.example?
Are Kubernetes Secrets safe if the values are base64?
Sources
- dotenv (motdotla) README: comments, quotes, multiline, trimming, empty values (checked 11 Nov 2026)
- dotenv lib/main.js: the LINE regular expression, CRLF handling, double-quote \n expansion, last duplicate wins (checked 11 Nov 2026)
- dotenv-expand README: ${VAR}, $VAR, ${VAR:-default}, ${VAR:+alternate} (checked 11 Nov 2026)
- Docker Compose: set environment variables (environment map and list syntax, env_file, ${VAR} interpolation) (checked 11 Nov 2026)
- Kubernetes: ConfigMaps (key characters, data field, 1 MiB limit) (checked 11 Nov 2026)
- Kubernetes: Secrets (stored unencrypted in etcd by default) (checked 11 Nov 2026)
- GitHub Docs: Secrets reference (name rules: alphanumeric and underscore, no GITHUB_ prefix, no leading digit) (checked 11 Nov 2026)
- POSIX Base Definitions, 3.216 Name (letters, digits, underscore; first character not a digit) (checked 11 Nov 2026)
Need a custom dev tool for your team?
We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter