Skip to main content

envdiff

PyPI version Python versions License: MIT

Diff .env-style files by keys without leaking secrets by default.

Install

pip install envkeydiff

Then run the CLI as envdiff:

envdiff --help

Why

Comparing .env.example to local or production env files often dumps secrets into terminal scrollback and CI logs. envdiff compares key presence (and optional emptiness) while masking values unless you explicitly opt in.

Usage

# Default when both exist in the current directory
envdiff

# Explicit paths
envdiff .env.example .env

# Multiple files (each compared against the first / baseline)
envdiff --json .env.example .env .env.production

# Fail on empty values; ignore noisy keys
envdiff --strict --ignore SECRET_INTERNAL --ignore-prefix TEMP_

Output sections

Section Meaning
missing_in_a Keys present in B but not in A (baseline)
missing_in_b Keys present in A but not in B
empty_values Keys present in both where at least one side is empty
present_in_both Shared keys (names only by default)

Flags

Flag Description
--json Machine-readable JSON
--show-values DANGEROUS — print secret values
--strict Treat empty values as failure (exit 1)
--ignore KEY Ignore an exact key (repeatable)
--ignore-prefix PREFIX Ignore keys with prefix (repeatable)
-V / --version Print version

Exit codes

Code Meaning
0 No key drift (and no empty values when --strict)
1 Missing keys, or empty values under --strict
2 Usage / file errors

Library API

from envdiff import parse_env_file, diff_env_files

entries = parse_env_file(".env")
result, _ = diff_env_files([".env.example", ".env"], ignore=["SECRET_INTERNAL"])
assert not result.has_drift(strict=True)

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT

Release files for envkeydiff 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for envkeydiff 0.1.0
File Size Uploaded
envkeydiff-0.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for envkeydiff 0.1.0
File Interpreter ABI Platform
envkeydiff-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / envkeydiff-0.1.0.tar.gz

Download URL envkeydiff-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e568cb352b429502d156507f83304ee34846a6f45b4e18508669db05e431d52
BLAKE2b-256 checksum
How to use checksums
2cd7f553fd2bf294b0d95f45b8b99bf8672de98ea1b0db39f6e67f66bb433fe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / envkeydiff-0.1.0-py3-none-any.whl

Download URL envkeydiff-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97f6e485525f65aba8420b6f580dedff60d3b9365f5b845b992165bc00c228ba
BLAKE2b-256 checksum
How to use checksums
0228b5cc25ee60a047f3bc12794e3471ace650d6bedda9e2e44cd42c7bd1a74b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page