How-to · 23 Oct
How-to · 3 min read
How to check a .env file for mistakes before you deploy
Your app works on your laptop and breaks in staging, and you suspect the .env file, which is full of passwords and keys you would not paste just anywhere. Reading it line by line rarely shows the problem. A stray quote, a duplicate key or a space in the wrong place looks fine to the eye. And the app usually does not complain, it just reads the wrong value.
01
Why it's hard
The dotenv format looks simple, so there is rarely a real check before a deploy. Different libraries parse the same file in slightly different ways, especially around quotes, comments, trailing spaces and variables that reference other variables. When a key appears twice, one of the values wins quietly, and which one depends on the parser. On top of that, the file is full of secrets, which is exactly why people avoid online checkers and end up trusting their eyes instead. So the mistake survives until it shows up as a confusing bug in an environment that is harder to debug.
This part describes the usual way. It makes no claims about DevTools Hub, so nothing is quoted here.
02
How DevTools Hub does it
DevTools Hub has an Environment Toolkit with five tools to validate, diff, resolve and convert .env files, built around the format's real parsing rules and the problems that fail without an error. Every tool on the site runs locally in your browser in JavaScript, so the file you paste is not sent to a server. The founder has confirmed that this holds for all 163 tools. That makes it a reasonable place to look at a file full of credentials. The tools are free web pages, so there is nothing to install before you start.
Validate, diff, resolve, and convert .env filesQuoted from devstoolshub.com
five tools for the dotenv format's real parsing rules and the gotchas that fail silently. All run entirely in your browser.Quoted from devstoolshub.com
that data is processed locally in JavaScript and never transmitted to a serverQuoted from devstoolshub.com
03
Step by step
- 1Open DevTools Hub and search for env, or go to the Environment Toolkit.
- 2Paste the contents of your .env file into the validator.
- 3Read what it flags and fix the lines in your editor.
- 4Use the diff tool to compare your local file with the staging or production version.
- 5Check how variables resolve if your file references one value from another.
- 6Convert the file to another format if your deploy target needs it.
04
Tips
Diff before you blame the code. When something works locally and fails elsewhere, comparing the two .env files side by side often shows a missing key or a value that changed in one place only. If you only care about which keys exist, blank out the values first and compare just the names.
General advice. Not a claim about the product.
Watch for keys that appear twice. It is easy to add a variable at the bottom of a long file without noticing it already exists higher up, and the result depends on which value the parser keeps.
General advice. Not a claim about the product.
If the same deploy also uses Docker Compose or Kubernetes manifests, check those in the same session. The site has separate toolkits for both, and an env value is often wrong because of how a Compose file passes it in.
Validate, lint, format, visualize, merge, and resolve Docker Compose filesQuoted from devstoolshub.com
Local processing protects the paste, but your own habits still matter. Close the tab when you are done and do not keep production secrets sitting in a shared clipboard tool. If a teammate needs to see the problem, share the key name and the fix, not the whole file.
General advice. Not a claim about the product.
05
Questions
Can I compare two .env files?
Yes. Diff is one of the five tools in the Environment Toolkit, next to validate, resolve and convert.
Validate, diff, resolve, and convert .env filesQuoted from devstoolshub.com
Does it check GitHub Actions workflows too?
Yes. A separate toolkit validates and lints workflows and audits them for secrets.
Validate, visualize, lint, and audit secrets in GitHub Actions workflowsQuoted from devstoolshub.com
Can it convert YAML config to JSON?
Yes. The YAML Toolkit validates and formats YAML and converts between YAML and JSON.
Validate and format YAML, and convert between YAML and JSONQuoted from devstoolshub.com