There is no formal .env specification, and Node, Python, Ruby, Go and Docker Compose each parse the file a little differently. What they agree on is enough to check: KEY=VALUE per line, keys made of letters, digits and underscores, balanced quotes, and no duplicates, because the last one silently wins.
What you'll learn
- Write lines every dotenv loader accepts
- Find duplicate keys before they overwrite each other
- Quote values with spaces, hashes or special characters correctly
Step by step
-
Paste the .env contents
Open the .env File Validator and paste the file. It stays in your browser; treat real secrets with the same care as anywhere else.
-
Click Validate
Each finding names the line. Errors are lines a loader will reject or misread; warnings are things that work but surprise.
DATABASE_URL=postgres://localhost/app DATABASE_URL=postgres://prod/app → WARNING duplicate, last value wins bad line here → ERROR not KEY=VALUE SECRET_KEY="unterminated → ERROR unbalanced quote debug=true → INFO keys are usually UPPER_SNAKE_CASE
-
Fix the file
Remove duplicates, close quotes, and quote any value that contains spaces or a # so it is not read as a comment.
Common problems
A value with a # got cut off
Unquoted # starts a comment in most loaders. Wrap the value in double quotes.
Variables are not expanding
Expansion of ${OTHER} depends on the loader and on quoting; single quotes usually disable it. Check your library's documentation.
FAQ
Should I commit .env files?
No. Commit a .env.example with placeholder values and keep the real file out of version control.