ENV guide
How to Validate Environment Variables Before Deployment
Environment configuration often fails at startup, far away from the commit that introduced the problem. A short validation pass catches structural mistakes before the deployment system or application has to interpret them.
Separate syntax checks from service checks
Syntax validation answers whether a file can be parsed predictably. It can detect invalid names, malformed assignments, duplicates, empty values, unresolved references, and suspicious whitespace.
It cannot prove that a database password is current or an API endpoint is reachable. Those are runtime checks and should use narrowly scoped health checks without printing credentials.
Treat duplicates as configuration debt
Many dotenv loaders keep the first or last duplicate assignment, but the behavior is not universal. A file with two PORT values forces readers to guess which one wins.
Remove duplicates and keep one source of truth. If an environment needs a different value, store the override in that environment instead of leaving competing lines in one file.
# Ambiguous PORT=3000 PORT=8080 # Clear PORT=8080
Use a deployment checklist
Validate the file, compare required keys against the template, and confirm that production-only variables are documented. Then run application startup validation so required values fail fast with names—not secret contents—in the error message.
- Reject malformed assignments and unresolved required references.
- Review every empty value instead of treating all empties as errors.
- Never print the full environment during CI troubleshooting.
- Rotate any credential that appears in logs, comments, or version control.
Apply the guide privately
EnvSift processes ENV content locally in your browser and does not send keys or values to a server.
Validate an ENV file