Skip to main content
Aarunya AppsAarunya Apps

How it works

  1. 1

    Paste or drop your file

    Drop a .env, .yaml, .json, or plain-text config — or paste the contents directly into the input area.

  2. 2

    Secrets are redacted instantly

    The tool scans for API keys, tokens, passwords, and database URLs using 15+ pattern rules — all in your browser.

  3. 3

    Copy or download the safe output

    Get a sanitized version and a ready-to-commit .env.example with <REDACTED> placeholders.

Before & after

⚠ Input — contains secrets

STRIPE_SECRET_KEY=sk_live_51AbcXYZ123realkey
DATABASE_URL=postgresql://user:pass123@prod.db.host:5432/mydb
NEXT_PUBLIC_APP_URL=https://myapp.com
OPENAI_API_KEY=sk-proj-AbCdEfG12345realkey
JWT_SECRET=my_super_secret_jwt_signing_key_2024

✓ Output — safe to share

STRIPE_SECRET_KEY=<REDACTED>
DATABASE_URL=<REDACTED>
NEXT_PUBLIC_APP_URL=https://myapp.com
OPENAI_API_KEY=<REDACTED>
JWT_SECRET=<REDACTED>

.env Sanitizer & Secret Scanner

Free

Redact secrets from config files — .env, .js, .yaml, .json, and more. 100% client-side — nothing leaves your browser.

Zero uploadsNo cookiesGDPR compliantOpen in DevTools — no network calls

Input

Drop any config file here

.env · .js · .yaml · .json · .ts · or paste below

🔒

Zero network requests

Every byte of processing happens inside your browser tab. Nothing is sent to any server.

🎯

Smart secret detection

Detects API keys, tokens, passwords, database URLs, and long random strings by key name and value patterns.

📋

Three outputs in one click

Sanitized file with REDACTED values, .env.example with blank values, and a diff showing what changed.

What gets detected? (15+ secret patterns)

API_KEY, API_SECRET

DATABASE_URL, DB_URL, DB_PASSWORD

SECRET, SECRET_KEY

TOKEN, AUTH_TOKEN, ACCESS_TOKEN, REFRESH_TOKEN

PASSWORD, PASSWD

PRIVATE_KEY, RSA_KEY

STRIPE_KEY, STRIPE_SECRET

GITHUB_TOKEN, GITHUB_PAT

OPENAI_API_KEY, ANTHROPIC_API_KEY

SENDGRID_KEY, SENDGRID_API_KEY

TWILIO_AUTH_TOKEN, TWILIO_SID

AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY

JWT_SECRET, NEXTAUTH_SECRET

GOOGLE_CLIENT_SECRET, OAUTH_SECRET

PUSHER_SECRET, PUSHER_APP_KEY

Any key containing a matched keyword has its value replaced with <REDACTED>. Safe values like URLs without credentials and boolean flags are preserved.

🛡️ Verify zero uploads — open DevTools → Network tab

Open your browser's DevTools (F12), go to the Network tab, and use this tool. You will see zero outbound requests — all processing runs inside your browser sandbox via WebAssembly or pure JavaScript. Nothing you paste or upload is ever sent anywhere.

⚠️ Security considerations

🔑

Rotate any key that has ever been in a committed .env file

If a secret has ever been in git — even for one commit — treat it as compromised. Sanitizing the file removes it from the working tree but git history retains it forever. Rotate the credential at the provider (Stripe, GitHub, AWS, etc.) immediately.

🚫

Never paste production secrets into an online tool you don't control

This tool processes entirely in your browser, but make it a habit to rotate secrets before sharing them anywhere. Test with invalidated or already-rotated tokens. If you must share real credentials, use a secrets manager (1Password Secrets, Doppler, HashiCorp Vault) — not .env files at all.

📋

.env.example should never contain real values

The purpose of .env.example is to document which variables exist, not what they are. Every value should be a placeholder like <REDACTED> or a description like your_stripe_secret_key. Committing real values here defeats the purpose.

🧹

Remove .env from git history, not just .gitignore

Adding .env to .gitignore prevents future commits but doesn't remove it from history. Use git filter-repo (preferred) or BFG Repo Cleaner to rewrite history. Then force-push and notify all collaborators to re-clone.

Use cases

Onboarding a contractor

Share a sanitized copy of your .env with none of the real credentials — they get the structure, not the secrets.

Generating .env.example

Instantly produce a clean template for your repository so new developers know what variables to set.

Pre-commit secret check

Paste your deployment config before every commit to catch accidentally included API keys or tokens.

Common mistakes

5 pitfalls to avoid

1Committing .env instead of .env.example

✗ Wrong: Adding the real .env file to git because the project worked without a .gitignore

✓ Fix: Always add .env* to .gitignore before the first commit. Commit only .env.example with placeholder values.

2Logging env vars for debugging

✗ Wrong: console.log(process.env) to check why a variable is undefined — which logs all secrets to your CI output

✓ Fix: Log only the specific variable you're checking: console.log('STRIPE_KEY defined:', !!process.env.STRIPE_SECRET_KEY). Never log the value.

3Hardcoding secrets as fallbacks

✗ Wrong: const key = process.env.API_KEY ?? 'sk_live_realkey' — so the app 'works' even without .env

✓ Fix: Throw at startup if a required secret is missing: if (!process.env.API_KEY) throw new Error('API_KEY is required'). Fail loudly, never silently use a hardcoded default.

4Storing secrets in NEXT_PUBLIC_ variables

✗ Wrong: NEXT_PUBLIC_STRIPE_SECRET_KEY=sk_live_... — which embeds the secret in the client bundle

✓ Fix: NEXT_PUBLIC_ variables are exposed to the browser. Only use them for public config (app URL, analytics ID). Server-only secrets must never have this prefix.

5Sharing .env over Slack or email

✗ Wrong: Pasting the full .env into a DM or email to onboard a new developer

✓ Fix: Use a secrets manager with per-person access (Doppler, 1Password Teams, AWS Secrets Manager). Each developer pulls their own credentials with proper audit logging.

Code snippets

Copy-ready integration examples

Node.js — load .env with dotenv
js
// npm install dotenv
import "dotenv/config"

// Or with explicit path:
import { config } from "dotenv"
config({ path: ".env.local" })

// Validate required vars at startup:
const required = ["DATABASE_URL", "STRIPE_SECRET_KEY", "JWT_SECRET"]
for (const key of required) {
  if (!process.env[key]) throw new Error(`Missing env var: ${key}`)
}
Next.js — access env vars correctly
tsx
// .env.local (never committed)
DATABASE_URL=postgresql://...
STRIPE_SECRET_KEY=sk_live_...
NEXT_PUBLIC_APP_URL=https://myapp.com  // browser-safe only

// In server code (app/api/route.ts, server actions):
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)

// In client code — only NEXT_PUBLIC_ vars are available:
const appUrl = process.env.NEXT_PUBLIC_APP_URL
Python — load .env with python-dotenv
python
# pip install python-dotenv
from dotenv import load_dotenv
import os

load_dotenv()  # loads .env from current directory

# Validate required secrets:
required = ["DATABASE_URL", "STRIPE_SECRET_KEY"]
missing = [k for k in required if not os.getenv(k)]
if missing:
    raise EnvironmentError(f"Missing env vars: {', '.join(missing)}")

stripe_key = os.environ["STRIPE_SECRET_KEY"]
Shell — check for leaked secrets before commit
sh
# Install git-secrets: https://github.com/awslabs/git-secrets
brew install git-secrets  # macOS
git secrets --install     # hooks into pre-commit

# Or use trufflehog for history scanning:
# pip install trufflehog
trufflehog git file://. --only-verified

# One-liner: scan working tree for common patterns:
grep -rE "(sk_live|sk_test|ghp_|AKIA[0-9A-Z]{16})" .   --include="*.env" --include="*.json" --include="*.ts"

Frequently Asked Questions

Is my .env file sent anywhere?

No. The redaction runs entirely in your browser using JavaScript regex patterns. Your file never leaves your device — there are no network requests made while you paste or type.

What types of secrets does it detect?

API_KEY, DATABASE_URL, SECRET, TOKEN, PASSWORD, PRIVATE_KEY, AUTH_TOKEN, ACCESS_TOKEN, STRIPE_KEY, GITHUB_TOKEN, OPENAI_API_KEY, SENDGRID_KEY, TWILIO_, AWS_, JWT_SECRET, and any key-value pair where the key contains common secret keywords.

Can I use the output directly as a .env.example file?

Yes. The tool generates a clean .env.example output where all secret values are replaced with <REDACTED> or descriptive placeholders. You can download it directly.

What file formats are supported?

.env, .env.local, .env.production, .yaml, .yml, .json, and plain-text config files. The tool detects KEY=VALUE patterns regardless of the file extension.

Does this work for Docker Compose env files?

Yes. Docker Compose environment: blocks use the same KEY=VALUE syntax, which this tool fully supports.

Can I use this in my terminal or CI pipeline?

Yes — the same engine is open source as a zero-dependency npm CLI. Run `npx @aarunyaapps/env-redact` to redact a file, `--example` to generate a .env.example, or `--check` in CI to fail the build when a file contains live secrets. Source: github.com/aarunyatech/env-redact.

Want unlimited access + saved history?

Pro is $6/month · 30-day money-back guarantee.

Embed or share this toollink · markdown · html · iframe
https://aarunyaapps.com/env-sanitizer
Powered by Aarunya Apps