Developer Tool
Runs in your browser. Nothing is uploaded.

.env File Compare & Checker

Compare .env with .env.example, find missing or extra keys, audit secret hygiene, and generate clean sanitized templates.

Audit & Generator Settings
Generator Placeholder Style:
Summary:
Drop .env file here
0 lines • 0 keys
Drop .env.example file here
0 lines • 0 keys

How to Compare and Validate .env Files

Maintaining strict parity between your development environment, staging clusters, production instances, and your version-controlled .env.example template is essential to preventing missing configuration crashes during cloud deployments. Follow these five simple steps:

  1. Paste Your Active .env File: Place your current working configuration into the left editor (File A).
  2. Paste Your Template or Target File: Place your repository template (.env.example) or comparison environment into the right editor (File B).
  3. Execute Deterministic Evaluation: Click Run Compare (or press Ctrl+Enter). The parser normalizes quotation escapes, strips inline comments, and computes bidirectional missing key sets.
  4. Audit Secret Hygiene & Syntax: Check the live summary chips and Results Matrix for leaked production secrets in File B, accidental duplicates, spaces around equal signs, or unquoted multiline values.
  5. Sync Missing Keys or Generate Clean Templates: Use the Generators dropdown to append missing keys to File A or generate an updated, sanitized .env.example with heuristic placeholders.

Before & After Example: Drift Resolution

Consider an application where a developer added a Stripe billing secret and an email service API key locally, but forgot to update the repository template before a team member pulled the latest code:

Before: Active .env vs. Outdated .env.example

# File A (.env - Active Production)
PORT=8080
DATABASE_URL="postgres://app_user:secret_pass@127.0.0.1:5432/main_db"
STRIPE_SECRET_KEY="sk_live_51M0abcdef1234567890"
EMAIL_API_KEY="SG.production_mail_key_9981"
PORT=8443  # Accidental duplicate! Last wins.

# File B (.env.example - Git Repository Template)
PORT=3000
DATABASE_URL="postgres://user:password@localhost:5432/mydb"
# STRIPE_SECRET_KEY and EMAIL_API_KEY are missing entirely!
# Accidental leaked token in template:
SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T00/B00/X123authentic"

After: Comparison Audit & Clean Generated Template

# Generated .env.example (Safe to Commit)
PORT=3000
DATABASE_URL=postgres://user:password@localhost:5432/dbname
STRIPE_SECRET_KEY=your_api_key_here
EMAIL_API_KEY=your_api_key_here
SLACK_WEBHOOK_URL=https://example.com

Why Environment Variable Parity Matters

In modern twelve-factor software engineering, all configuration that varies across deployment stages (such as databases, cryptographic credentials, cache hosts, and third-party SaaS endpoints) must be stored strictly in the environment. However, because environment variable files are deliberately excluded from git via .gitignore, teams inevitably experience configuration drift.

A single missing environment variable can cause microservices to fail silently on boot, crash container orchestrators, or trigger unexpected runtime undefined errors deep in request pipelines. Regular parity checks verify that every service dependency is accounted for across all staging, developer, and CI/CD environments without exposing private secrets.

Common Dotenv Mistakes and Edge Cases

  • Spaces Around the Equal Sign: Declaring KEY = value or KEY= value is valid in standard INI files, but breaks POSIX shell exports and standard dotenv libraries in Node.js, Python, and Go.
  • Unmatched and Smart Quotes: Copying environment variables from rich text documents or messaging apps frequently introduces typographic curly quotes (“ ” ‘ ’), causing silent syntax errors.
  • Duplicate Keys and Shadowing: When a key is declared twice, standard parsers resolve assignments top-to-bottom so the last occurrence wins. Shadowed keys often cause perplexing configuration bugs.
  • Multiline Keys: RSA private keys and SSL certificates require proper encapsulation in double quotes with newline escapes or physical line breaks.
  • Leaking Secrets in Examples: Committing real API keys inside .env.example is one of the leading causes of automated token scraping on public repositories.

Frequently Asked Questions

How do I compare .env and .env.example?
Paste your active .env file into File A on the left, and your .env.example or template file into File B on the right. Click 'Run Compare' or press Ctrl+Enter. The tool compares key presence, detects missing variables, flags unquoted spaces or syntax bugs, and inspects template values for leaked production secrets.
Should I commit .env?
No. Never commit your active .env file containing genuine production credentials, database connection strings, or private API tokens to source control. Always commit only a sanitized .env.example template with dummy placeholders.
Is it safe to paste my .env here?
Yes, completely safe. This tool runs 100% in your local browser memory using deterministic client-side JavaScript. There is no backend, no analytics on user content, no network transmissions, and nothing is ever uploaded to any server. As a general engineering best practice, however, avoid pasting live master keys into browser windows on shared or untrusted machines.
What does 'last duplicate wins' mean?
In the standard dotenv parsing specification, variables are evaluated line by line from top to bottom. If a key is defined more than once in the same file, the final declaration overwrites all previous occurrences. This tool identifies duplicated keys and marks the last occurrence as the active effective value.
How does secret hygiene detection work?
The engine scans all values inside File B (.env.example) against pattern matchers for authentic credentials (such as AWS AKIA identifiers, Stripe live secret keys, GitHub personal access tokens, Slack bot tokens, JWT tokens, and cryptographic PEM private keys), as well as Shannon entropy analysis. Any suspected real credentials in a template trigger a red warning before committing.
Can I compare staging, dev, and production simultaneously?
Yes. Click the '+ Add third file' button in the toolbar to activate a third split pane (e.g., .env.staging). The parity matrix automatically expands to cross-reference all three environments concurrently.