Let's be honest: dotenv is a plaintext file sitting in your project directory with no encryption, no authentication, and no access control. It has 22 million weekly npm downloads. That's 22 million projects where every secret is one cat .env away from exposure.
We used .env files for years. Then we counted them — 47 across our projects. Same Stripe keys copy-pasted everywhere. Same database URLs. Any process running as our user could read all of them, including AI coding agents that now have full file system access.
So we replaced them. Here's what we tried and what we actually think about each option.
Why dotenv stopped being good enough
Dotenv came out of the Ruby community as a way to stop hardcoding credentials in source files. Move secrets to .env, add it to .gitignore, read values with process.env. Simple. Genuinely better than what came before.
But the world changed. In 2012, the main risk was accidentally committing a file to git. In 2026, the problems are bigger:
- AI agents read your project files. Claude Code, Cursor, Copilot, Codex — they all have file system access. Your
.envis just another file to them. Once a secret enters an agent's context window, it can show up in generated code, logs, or shared conversations. That's not a hypothetical. It happens. - Supply chain attacks go after plaintext credentials. Malicious npm packages and VS Code extensions scan for
.envfiles. No hacking required — they're just files sitting there. - Secrets sprawl gets out of hand fast. Most developers have dozens of
.envfiles across their machine. Same keys everywhere. Try rotating a credential and knowing you caught every copy. Good luck. - No audit trail whatsoever. Nothing logs which process read which secret, or when. If something leaks, your incident response starts with
grep -rand hope.
Dotenv was never a security tool. It was a convenience pattern. That's fine for 2012. It's not fine when AI agents are reading your project directory.
6 dotenv alternatives, compared honestly
We tested each of these as a replacement for .env files in local development. Not CI/CD — that's a different problem with different tools. This is about the secrets sitting on your laptop right now.
1. NoxKey — macOS Keychain + Touch ID
Full disclosure: we built NoxKey. So take this section with that in mind. We'll be honest about the limitations.
NoxKey stores secrets in the macOS Keychain, protected by the Secure Enclave and Touch ID. It's a CLI and menu bar app built for developer workflows — not repurposed from a password manager.
# Store a secret
$ noxkey set myorg/project/STRIPE_KEY --clipboard
✓ Stored myorg/project/STRIPE_KEY
# Use it — Touch ID on every access
$ eval "$(noxkey get myorg/project/STRIPE_KEY)"
# Import an existing .env file
$ noxkey import myorg/project .env
✓ Imported 5 secrets
The thing we're most proud of: AI agent detection. When an AI coding agent calls noxkey get, it inspects the process tree, spots the agent, and returns an encrypted handoff instead of the raw value. The secret reaches your environment but never enters the agent's context window.
Pros: Free and open source. No account, no cloud. Hardware encryption via Secure Enclave. Touch ID on every access. AI agent detection built in. Fast — secrets load in milliseconds.
Cons: macOS only. Full stop. If you're on Linux or Windows, this isn't an option. No team sharing either — it's a single-machine tool by design. If you need to share secrets across a team, you'll need something else.
Price: Free, open source.
2. 1Password CLI (op)
If your team already pays for 1Password, their CLI is a solid choice. It lets you reference secrets from your vault in shell commands and config files without maintaining separate .env files.
# Reference a secret
$ op run --env-file=.env -- npm start
# Inject into a command
$ op read "op://Development/Stripe/secret_key"
We've used this on projects where the team was already on 1Password. It works well. The op run command is genuinely nice — point it at an .env template with 1Password references and it resolves them at runtime.
Pros: Cross-platform. Team sharing with real access control. Secret rotation and audit logs. Solid CI/CD integrations. Actively maintained by a company that takes security seriously.
Cons: Requires a 1Password subscription ($36/year per user). Your secrets live in 1Password's cloud — not local-first. The CLI can be sluggish on first invocation (it phones home). No awareness of AI agents reading your environment.
Price: $36/year (Individual), $60/year (Families), $96/year (Teams).
3. direnv
We love direnv for what it does. It loads and unloads environment variables based on the current directory — cd into a project and your env is set, cd out and it's gone. Elegant.
# .envrc
export STRIPE_KEY="sk_live_..."
export DATABASE_URL="postgresql://..."
Here's the thing though: direnv isn't a secrets manager. It's a loading mechanism. Your .envrc is still a plaintext file on disk with the same problems as .env. We still use direnv — but we pair it with NoxKey so the .envrc calls a secrets manager instead of containing secrets. More on that below.
Pros: Elegant directory-scoped loading. Works with any shell. Can source secrets from other tools (combine with op or noxkey). Free and open source.
Cons: Not a secrets manager. Your .envrc is still plaintext on disk. No encryption. No authentication. Solves the loading problem, not the storage problem. Same AI agent risk as .env if you put actual values in it.
Price: Free, open source.
4. HashiCorp Vault
Vault is the enterprise standard for secrets management. Dynamic secrets, encryption as a service, fine-grained access policies. If you run production infrastructure at scale, you probably already have it — and your security team definitely has opinions about it.
# Read a secret
$ vault kv get -field=api_key secret/myproject/stripe
We respect Vault, but we'd never recommend it for local development unless your org already runs it. The operational overhead is enormous. You need a Vault server, you need to configure auth backends, you need to manage policies. It's infrastructure, not a dev tool.
Pros: Dynamic secrets that auto-expire. Comprehensive audit logging. Encryption as a service. Fine-grained access policies. Every compliance team loves it.
Cons: Massive overkill for local development. You need to run a Vault server (or pay for HCP Vault). Complex setup with a steep learning curve. It solves enterprise problems, not "I have 47 .env files on my laptop" problems.
Price: Free (self-hosted, OSS), HCP Vault starts at ~$0.03/secret/month, Enterprise pricing on request.
5. Doppler
Doppler is a cloud SaaS for managing secrets across environments. It syncs secrets to your local machine, CI/CD, and cloud providers through one dashboard. For small teams that want a managed solution without running their own infrastructure, it's well-designed.
# Run a command with secrets injected
$ doppler run -- npm start
# Set a secret
$ doppler secrets set STRIPE_KEY sk_live_...
The dashboard is clean, the CLI is straightforward, and the environment syncing (dev/staging/prod) actually works well. Our concern is the same one we have with any cloud-hosted secrets tool: your secrets live on someone else's servers. For some teams that's fine. For us, it's a dealbreaker.
Pros: Clean dashboard. Team sharing with roles and permissions. Environment syncing that actually works. Good CI/CD integrations. Version history on secrets.
Cons: All your secrets live in Doppler's cloud. Free tier limited to 5 team members. Vendor lock-in — migrating away means extracting everything. No offline access. No AI agent awareness.
Price: Free (up to 5 users), Team $6/user/month, Enterprise pricing on request.
6. macOS Keychain (native security CLI)
Here's the thing nobody talks about: you already have a hardware-encrypted secrets manager on your Mac. The Keychain is backed by the Secure Enclave, and you can access it from the terminal with the security command.
# Store a secret
$ security add-generic-password -a "$USER" -s "myproject-stripe-key" \
-w "sk_live_..." -T ""
# Retrieve it
$ security find-generic-password -a "$USER" -s "myproject-stripe-key" -w
We tried this before building NoxKey. The security is genuinely good — hardware encryption, Touch ID, the whole stack. The developer experience is genuinely terrible. No namespacing, no import/export, no session management. The security CLI feels like it was designed for system administrators in 2005, not developers in 2026. (We wrote about the experience in detail.)
Pros: Free. Already installed. Hardware encryption. No third-party dependencies. Touch ID support (when you get it configured correctly).
Cons: Awful DX. The security CLI wasn't designed for managing developer secrets. No namespacing, no bulk import, no session management, no AI agent detection. You'll spend more time fighting access control groups than writing code.
Price: Free (built into macOS).
Comparison table
| Tool | Encryption at rest | Authentication | AI agent safe | Platform | Team sharing | Price |
|---|---|---|---|---|---|---|
| dotenv (.env) | None | None | No | Any | Copy files | Free |
| NoxKey | AES-256 (Keychain) | Touch ID | Yes (agent detection) | macOS | No | Free |
| 1Password CLI | AES-256 | Master password / biometrics | No | Any | Yes | $36+/yr |
| direnv | None | None | No | Any (Unix) | No | Free |
| HashiCorp Vault | AES-256-GCM | Tokens / OIDC / LDAP | No | Any | Yes | Free (OSS) / $$ |
| Doppler | AES-256 | SSO / password | No | Any | Yes | Free–$6/user/mo |
| macOS Keychain | AES-256 (Secure Enclave) | Touch ID / password | No | macOS | No | Free |
Which one should you actually use?
Here's how we think about it:
Solo developer on macOS who values privacy: NoxKey. Free, local-first, hardware encryption, AI agent detection. Download NoxKey, import your .env files, delete them. Done in an afternoon.
Team already paying for 1Password: 1Password CLI. You're paying for it anyway — use it. op run integrates cleanly into existing workflows, and you get team sharing without adding another tool.
Enterprise with compliance requirements: HashiCorp Vault. It's overkill for local dev, but if your security team requires it, it checks every box they care about.
Small team that needs cloud sync: Doppler. Clean experience, reasonable pricing, good integrations. You're trusting them with your secrets, but for many teams that trade-off makes sense.
Already using direnv: Keep it — but pair it with a real secrets backend. Use direnv for loading and NoxKey or op for storage. Your .envrc should call a secrets manager, not contain secrets:
# .envrc — loads secrets from NoxKey, no plaintext on disk
eval "$(noxkey get myorg/project/STRIPE_KEY)"
eval "$(noxkey get myorg/project/DATABASE_URL)"
Cross-platform team (Linux + macOS + Windows): 1Password CLI or Doppler. NoxKey and native Keychain are macOS-only. Vault works everywhere but the setup cost is steep.
How to migrate away from .env files
Whatever tool you pick, the migration follows the same pattern:
- Find every .env file on your machine. You probably have more than you think.
$ find ~/dev -name ".env" -not -path "*/node_modules/*" -not -path "*/.git/*" | wc -l - Import each one into your chosen tool.
- Update your workflow — replace
source .envor dotenv calls with your tool's CLI equivalent. - Delete the .env files. Not archive. Delete. A plaintext file you're "not using anymore" is still a plaintext file on disk.
- Update .env.example files in your repos to document which keys are needed, without values.
We did this across 47 projects in one afternoon. Here's the full story.
dotenv stores production credentials as plaintext files with zero protection. In 2026, with AI agents reading project files and supply chain attacks targeting credentials, that's not good enough anymore. Pick a real secrets manager — any of the six above — and delete your .env files. It takes an afternoon. The risk of not doing it gets worse every month.
Frequently asked questions
- What's the best dotenv alternative in 2026?
- Depends on your setup. For solo macOS developers, NoxKey gives you free, hardware-encrypted storage with Touch ID and AI agent detection. For teams, 1Password CLI or Doppler handle cross-platform secrets with sharing built in. For enterprises, HashiCorp Vault remains the standard.
- Why should I replace .env files?
.envfiles store secrets as plaintext with no encryption, no authentication, and no access control. AI coding agents (Claude Code, Cursor, Copilot) can read them and expose secrets in their context windows. Supply chain attacks target them. And once you have dozens of them, rotating a key becomes a nightmare. More on why .env files are a liability.- Is direnv a good replacement for dotenv?
- direnv solves a different problem — it loads environment variables per directory, which is genuinely useful. But it still stores secrets in plaintext
.envrcfiles. Use direnv for the loading mechanism, but pair it with a real secrets manager (NoxKey, 1Password, etc.) for storage. - Can I use dotenv alternatives with AI coding agents?
- Most secrets managers protect secrets at rest but expose them as plaintext environment variables at runtime — which means an AI agent can still read them. NoxKey is the only tool on this list that actively detects AI agents via process tree inspection and blocks raw secret values from entering the agent's context.
- How do I migrate from .env files to a secrets manager?
- Find every
.envfile on your machine, import them into your chosen tool, update your scripts to use the tool's CLI instead ofsource .env, and delete the.envfiles. With NoxKey:noxkey import myorg/project .env, thenrm .env. We migrated 47 projects in one afternoon.