Have you ever spent way too long debugging a broken app, only to realize your .env file silently changed?
Yeahโฆ me too.
Thatโs why I built env-snapper โ a simple CLI tool to help developers take snapshots of their .env files and compare them over time.
๐ง Why I built it
Environment variables are essential for modern apps, but they're also fragile.
One typo, one missing variable, or an accidental overwrite โ and suddenly your app doesnโt work, or worse, it's working weirdly.
If youโre working across different machines, teams, or environments, tracking what changed (and when) in your .env can be a headache.
So I thought: โWhy not just snapshot it and compare later?โ
โ๏ธ What env-snapper does
Hereโs what it brings to the table:
โ Snapshot your current .env file
โ Automatically timestamp and version each snapshot
โ Diff between snapshots to spot changes
โ CLI interface (easy to use via npx)
โ No dependencies on external services โ local and fast
๐ ๏ธ How to use it
npm install -g env-snap
## Initialize env-snap in your project
npx env-snap init
# Manually snapshot current .env
npx env-snap snapshot
# List all snapshots
npx env-snap list
# Revert to a previous snapshot
npx env-snap revert <snapshot-id>
# Show diff between snapshots or with current .env
npx env-snap diff <snapshot-id> # Compare with previous snapshot
npx env-snap diff <snapshot-id> --current # Compare with current .env
# Watch .env for changes and snapshot automatically
npx env-snap watch
# Add a description to a snapshot (after creation)
npx env-snap desc <snapshot-id> "Your description here"
# Example: create a snapshot with a description
npx env-snap snapshot --desc "Added Sentry config and removed Stripe keys"
# Prune old snapshots, keeping only the latest 5 (default)
npx env-snap prune
# Prune and keep only the latest N snapshots (e.g., 10)
npx env-snap prune 10
# Preview changes before restoring a snapshot
npx env-snap preview <snapshot-id>
You'll see a clean, side-by-side diff of what changed between your last two snapshots.
๐ก Use cases
๐งช Testing config changes between deployments
๐ฏ Collaborating across teams with different environments
๐ ๏ธ Debugging issues caused by subtle .env tweaks
๐งณ Moving between machines without losing setup details
๐ฆ Get it now
You can check out the package here:
๐ https://www.npmjs.com/package/env-snapper
The code is open source and Iโd love your feedback, feature requests, or PRs!
๐ฌ Letโs connect!
Got questions, ideas, or bugs? Drop a comment below or reach out on X/Twitter [@HustleStacked].
Letโs keep our environments sane. ๐
Top comments (0)