.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

Parsed in this tab only. Values are masked in all results. Never paste a production file you are not allowed to share.

Names are compared; the example file is committed, so it should hold no real secrets.

Resolves ${VAR}, $VAR, ${VAR:-default} and ${VAR:+alternate} from the variables in this file, to find undefined and circular references.

A value that looks secret is never shown, whichever you pick.

Comma-separated key names that go in the Secret and are never shown, on top of the ones the checker detects.

.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
Variables dotenv would load (9; later duplicates win)
LineNameValueFlags
2NODE_ENV••••••ok
10PORT••••••duplicate
4APP_NAME••••••ok
5DEBUG••••••export
6DB_HOST••••••ok
7DB_URL••••••secret
8RAZORPAY_KEY_SECRET••••••secret
9SENTRY_DSN(empty)empty
11my-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 / environment

Which .env mistakes does this find, and what does dotenv do with them?

What dotenv does with common .env problems, and what this checker reports
Problemdotenv doesReported as
Line with no =Ignores it silentlyError with the line number
Same name twiceKeeps the last valueWarning listing the lines
Unquoted value with spacesKeeps it, trimmedWarning: a shell would split it
Unquoted # inside a valueTreats it as a comment and cuts the valueWarning
Quote not closed or text after itKeeps the quote characters in the valueError
KEY=Empty string (not unset)Note
Name with . or - or leading digitAccepts itWarning: not a valid shell or Actions name
${VAR} not defined in the filedotenv-expand also checks process.envWarning
Name in .env.example but not in .envNothingError
Real-looking secret valueLoads itWarning (error in .env.example); value never shown

How to validate a .env file

  1. 1
    Paste 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.
  2. 2
    Add 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.
  3. 3
    Read the findingsFix errors first (ignored lines, unclosed quotes, missing names), then warnings. Each one gives the line number and the name, never the value.
  4. 4
    Convert 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?
The parsing runs in your browser and the file is not sent anywhere, and no value appears in any result. A page you paste a secret into can still read it, though, so for a production file replace the real values with fake ones first and run the check on that copy.
Why does my value get cut off at a # sign?
dotenv treats # as the start of a comment unless the value is wrapped in quotes, so PASSWORD=ab#cd loads as ab. Put quotes around any value that contains a #, like PASSWORD="ab#cd".
Does an empty value mean the variable is unset?
No. dotenv reads KEY= as an empty string, so the variable exists with no text in it. Code that checks whether a variable is set will see it as set. Delete the line if you mean unset.
Why does a line with spaces in the value work in dotenv but break in my shell?
dotenv trims the value and keeps the spaces inside it, but a shell running source .env reads KEY=a b as KEY=a followed by a command named b. Wrap values with spaces in double quotes so both agree.
How does ${VAR} expansion work in a .env file?
With dotenv-expand, a value can use ${VAR}, $VAR, ${VAR:-default} to fall back when VAR is unset or empty, and ${VAR:+alternate} to use another value when VAR is set. dotenv alone does not expand anything, so check which loader your app uses.
What should go in .env.example?
Every name the app reads, with empty values or safe placeholders, and comments explaining each. It is committed to git so a new developer can copy it to .env, so it must never hold a real secret. The checker flags a real-looking one.
Are Kubernetes Secrets safe if the values are base64?
No. Base64 is an encoding, not encryption, and Kubernetes' own docs warn that Secrets are stored unencrypted in etcd by default. Turn on encryption at rest, limit who can read Secrets, and consider an external secret store. This page's Secret has placeholder values only.

Sources

Related tools

See all 135 free tools

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