Env Merge
BetaMerge a base .env file with an overlay .env file, choose which side wins when a key differs, and download one merged .env. Runs in your browser; the files are not uploaded.
- Free, no sign-up
- Updated
- Reviewed by Olgun Ozoktas
When a key has different values, the overlay value is used. This is how most tools layer .env.local over .env.
Add a base file and an overlay, then press Merge
Paste or drop the base .env on the left and the file whose values should be layered on top on the right, for example .env and .env.local. Load sample shows two conflicts and an empty override.
Runs in your browser; the files are not uploaded. Analytics and ads may load on the page.
Why Use Env Merge?
Env Merge combines two dotenv files into one. Both files are read with the dotenv rules: blank lines and # comment lines are skipped, a leading export is removed, quotes are unwrapped, backslash escapes are decoded inside double quotes, a double-quoted value may span several lines, and an inline # comment after an unquoted value is cut off. A key defined twice in one file keeps its last value, and a warning names the lines.
Every key from both files ends up in the output. A key found only in the base or only in the overlay is copied as it is. A key found in both with the same value is written once. A key found in both with different values is a conflict, and the rule you choose decides it: Overlay wins takes the overlay value, Base wins keeps the base value, Overlay wins unless its value is empty keeps the base value when the overlay leaves the key empty, and Stop and list the conflicts merges nothing and names the keys instead. Every conflict is listed with both values and the one that was used; secret-looking values in that table are hidden by default.
The merged file follows the base key order, with overlay-only keys appended at the end, or is sorted alphabetically when you ask. Values are written unquoted when they can be and in double quotes with escapes when they must be, and export can be written before every line. Comments are not carried over, and the page says so when either file had them. Env Merge does not expand ${VAR} references and does not sync with any secrets manager. To see every difference between two files first, use Env Diff; to check the merged file, use Env Linter.
How it compares
Merging by hand or with a shell loop such as cat .env .env.local works only if the program that reads the result lets the last line win, and it never tells you which values were overwritten. Env Merge writes each key once, applies the rule you picked, and lists every conflict. It parses both files in your browser instead of posting them to a server, and converts nothing else: for JSON or YAML output use the Env JSON Converter or the Env YAML Converter.
Tips for Merging .env Files
- The output keeps the base file's key order and appends keys that exist only in the overlay at the end, in the overlay's order. Turn on Sort keys A to Z for an alphabetical file instead.
- Comments and blank lines are not carried into the merged file. Keep the commented original if you need its notes.
- Values are written unquoted unless they need quotes: a value with a space, a #, a quote, a backslash or a line break is written in double quotes with escapes.
- Choose Stop and list the conflicts to see every disagreement first, then pick a rule once you know what will be overwritten.
- To see every difference between the two files, not only conflicts, use Env Diff.