Compare dotenv files and find missing, extra, and empty variables.
Install from the repository:
python -m pip install git+https://github.com/bam0ny/dotenv-diff.gitFor local development, install it in editable mode from the project directory:
python -m pip install -e ".[dev]"Compare the expected file with the actual file:
dotenv-diff .env.example .envExample output:
Missing:
DATABASE_URL
JWT_SECRET
Extra:
DEBUG_SQL
Empty:
REDIS_URL
Use --strict in CI to return exit code 1 when differences are found:
dotenv-diff .env.example .env --strictUse --json for machine-readable output:
dotenv-diff .env.example .env --jsonShow the installed version:
dotenv-diff --versionCreate .env.example from .env with empty values:
dotenv-diff --initWhen passing paths to --init, the order stays the same as comparison mode:
the example file comes first, then the actual file.
dotenv-diff --init .env.example .envIf .env.example already exists, use --force to overwrite it:
dotenv-diff --init --forcedotenv-diff supports common .env lines:
DATABASE_URL=postgres://localhost/app
EMPTY=
export DEBUG=true
SECRET="value # not a comment"
TOKEN='abc#123'
HOST=localhost # inline commentBlank lines and full-line comments are ignored. Lines without = are treated
as parse errors so broken configuration fails loudly.
python -m pip install -e ".[dev]"
python -m pytestMIT