Diff .env files by keys without leaking secrets
Project description
envdiff
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file envkeydiff-0.1.0.tar.gz.
File metadata
- Download URL: envkeydiff-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e568cb352b429502d156507f83304ee34846a6f45b4e18508669db05e431d52
|
|
| MD5 |
8136122f146aa2023fecb76d582d1fc9
|
|
| BLAKE2b-256 |
2cd7f553fd2bf294b0d95f45b8b99bf8672de98ea1b0db39f6e67f66bb433fe4
|
File details
Details for the file envkeydiff-0.1.0-py3-none-any.whl.
File metadata
- Download URL: envkeydiff-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97f6e485525f65aba8420b6f580dedff60d3b9365f5b845b992165bc00c228ba
|
|
| MD5 |
c1cf8f0bfb3e55d4cad43615a3207123
|
|
| BLAKE2b-256 |
0228b5cc25ee60a047f3bc12794e3471ace650d6bedda9e2e44cd42c7bd1a74b
|