---
title: "Env Merge"
description: "Merge 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."
url: https://findutils.com/developers/env-merge/
category: developers
---

# Env Merge

Merge 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.

**Use this tool:** [Env Merge](https://findutils.com/developers/env-merge/)

## Programmatic access

- Browser-only: this tool works on a file, the DOM, or a browser API and has no REST or MCP id.

## Why Use Env Merge?

Layering environment files is a daily chore: a shared .env with a personal .env.local on top, a template filled in with a teammate's values, or a staging file patched with a few production settings. Copying keys across by hand drops one sooner or later, and a quick shell loop does not tell you which values it overwrote. Env Merge takes a base file and an overlay, keeps every key from both, applies the conflict rule you pick, and shows each conflict with the value that won, so the merged file holds no surprises.

## Frequently Asked Questions

### How do I merge two .env files?

Paste or drop the base file into Base (A) and the overlay into Overlay (B), pick a conflict rule, and press Merge. The merged file appears with counts, a list of conflicts and the value used for each, and a button to download it as merged.env.

### Which value wins when both files define the same key?

The one your rule picks. Overlay wins is the default and uses the overlay value. Base wins keeps the base value. Overlay wins unless its value is empty keeps the base value when the overlay value is empty. Stop and list the conflicts merges nothing and names every key with different values. A key with the same value in both files is not a conflict.

### In what order are the keys written?

In the base file's order, with keys that exist only in the overlay appended at the end in the overlay's order. Turn on Sort keys A to Z to write them alphabetically instead.

### Are comments kept?

No. Comments and blank lines are not carried into the merged file, and a warning appears when either file had comments. Keep the original files if you need their notes.

### How are values quoted in the output?

A value is written unquoted when it can be. A value containing whitespace, a #, a quote, a backslash or a line break, or with leading or trailing spaces, is written in double quotes, with backslashes, quotes, line breaks and tabs escaped.

### What if the overlay file is empty?

The base is written out on its own, in the same normalized KEY=value form. The base file cannot be empty; the page asks for one.

### Does it expand $VAR or ${VAR} references?

No. Values are copied exactly as written, references included. Nothing is executed.

### Are my .env files uploaded?

No. Both files are parsed and merged in your browser, and the text is not sent in any request. Analytics and ads may load on the page as on the rest of the site. There is no API version of this tool on purpose, because .env files usually hold secrets.

### Can the output start every line with export?

Yes. Turn on Write export before each line to get a file a shell can source. An export prefix in the input files is always accepted and removed while reading.

## Related Tools

- [Env Diff](https://findutils.com/developers/env-diff/)
- [Env Linter](https://findutils.com/developers/env-linter/)
- [Env JSON Converter](https://findutils.com/developers/env-json-converter/)
- [Env YAML Converter](https://findutils.com/developers/env-yaml-converter/)
- [TOML Diff](https://findutils.com/developers/toml-diff/)
