What is the Compare tab?
The Compare tab shows every variable across every .env file in the project in a single matrix view. Rows where values differ are highlighted, so you can scan top-to-bottom and spot anything that looks off across environments.
One row per variable, one column per file. Your .env.example gets a column too, which is often where the surprises are.
It flags two different things, and they are worth telling apart:
- A key that is in one file and not another shows as a red
missingmarker in the column it is absent from. Something exists in one environment and was never carried across to the others. - A key that is everywhere but holds different values highlights the whole row. That may be a problem or may be the entire point.
The toolbar has a search box and three filters: All, Differences and Missing, the last two carrying a count when there is anything to count. Missing is the one to start on, because a missing key is unambiguous. Differences will always have permanent residents, so it rewards a slower read.
Two environments diverge for about four reasons, and the right response is different for each:
- A variable was added locally and never propagated. The usual case. Add it to the environments that need it.
- The value is meant to differ.
APP_ENV,APP_DEBUG, a database host, a payment key in test mode against one in live mode. Leave them alone. They will sit in the Differences filter forever, and that is correct. - Something is left over. A service you removed from one environment and not the others. Delete the stale key rather than copying it onward.
- A placeholder was never filled in. An empty value is marked
emptyrather than left blank, so it stands out next to a real value in the neighbouring column.
Compare never writes to a file. Clicking any cell opens the Diff tab focused on that variable, which is where changes actually get made. Dotvault will add a key that is missing from one side for you, one at a time or in bulk. It will not overwrite a value that disagrees, because it has no way of knowing which of the two is the right one, and quietly picking one would be worse than leaving it to you.
Encrypted env files are included, using their decrypted values, as long as you have unlocked them on this machine already. Dotvault can only compare what it can read.
If you want the workflow rather than the tour, the guide on syncing env files across environments covers Compare, the Diff tab and the .env.example prompt together. Manual two-file comparison is in its own answer, and if the two files you are comparing are .env and .env.local, there is a guide on which one is which.