Valid vs Invalid .env Syntax
Valid
# Simple key=value
DATABASE_URL=postgres://localhost/db
PORT=3000
DEBUG=false
# Quoted value with spaces
APP_NAME="My App"
SECRET_KEY='abc123xyz'
DATABASE_URL=postgres://localhost/db
PORT=3000
DEBUG=false
# Quoted value with spaces
APP_NAME="My App"
SECRET_KEY='abc123xyz'
Invalid
# Space around = sign
DATABASE_URL = postgres://...
# Unquoted value with spaces
APP_NAME=My App
# Missing value
API_KEY=
# Inline comment in value
PORT=3000 # main port
DATABASE_URL = postgres://...
# Unquoted value with spaces
APP_NAME=My App
# Missing value
API_KEY=
# Inline comment in value
PORT=3000 # main port
How to Use It
1
Open the tool
Go to Dev Utilities and scroll to the ENV Validator.
2
Paste your .env file
Paste the contents of your .env file. Values are processed locally — secrets do not leave your browser.
3
Define required keys
Enter the list of required variable names — typically taken from your .env.example file.
4
Review results
See which variables are missing, empty or malformed. Fix them before deploying.
Pro Tips
💡Maintain a
.env.example file in your repo with all required keys and placeholder values. New developers copy it to .env and fill in real values — and you always know what's required.💡Validate environment variables at application startup, not lazily when they're first accessed. A startup crash with a clear "missing: DATABASE_URL" message is far easier to debug than a cryptic runtime error.
💡Use
envalid (Node.js), pydantic-settings (Python) or similar libraries to enforce types and formats in code — e.g. ensuring PORT is a number and DATABASE_URL is a valid URL.Frequently Asked Questions
What is a .env file?
A file of
KEY=value pairs for environment-specific configuration — API keys, database URLs, port numbers, feature flags. Loaded at runtime to keep config out of source code.Should I commit .env to git?
No — it often contains secrets. Add
.env to .gitignore. Commit .env.example with placeholder values so teammates know which variables are required.How do I validate ENV variables in code?
Libraries:
envalid (Node.js), pydantic-settings (Python), viper (Go). They validate at startup and throw descriptive errors for missing or invalid variables.What are common .env formatting mistakes?
Spaces around
=, unquoted values with spaces, trailing whitespace after values, and using # inside quoted values without escaping. All can cause silent parse failures.Validate your .env file now
Open the ENV Validator and check for missing or malformed environment variables — free, instant, no login.
Open ENV Validator →