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
# Show diff between snapshots or with current .env
npx env-snap diff # Compare with previous snapshot
npx env-snap diff --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 "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
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. 😄