.env Validator & Environment Variable Comparator
Validate .env files, detect syntax errors, duplicate keys, empty values, potential secrets, compare environments, find missing variables, and review configuration drift.
⚠ Configured with warnings or detected secrets
DATABASE_URL#SECRET_DETECTEDPotential secret detected in 'DATABASE_URL' [Connection URI with Embedded Password]. Masked by default.
JWT_SECRET#SECRET_DETECTEDPotential secret detected in 'JWT_SECRET' [Sensitive Variable Name Heuristic]. Masked by default.
SESSION_SECRET#SECRET_DETECTEDPotential secret detected in 'SESSION_SECRET' [Sensitive Variable Name Heuristic]. Masked by default.
How to Use
1. What is a .env File and Why is it Used?
A .env file is a plain text configuration file containing key-value pairs that define operating system environment variables for software applications. Popularized by the Twelve-Factor App methodology (Principle III: Config), storing configuration in the environment strictly separates runtime credentials, connection endpoints, and host settings from application source code.
Modern backend and frontend runtimes (such as Node.js, Next.js, Python Django/FastAPI, Ruby on Rails, Go, Docker, and Kubernetes) load .env files at boot time to initialize database connection pools, third-party API keys, port bindings, and runtime feature flags without hardcoding sensitive secrets in Git repositories.
2. Standard Dotenv Syntax Rules & Quoting Conventions
Standard keys use uppercase alphanumeric characters with underscores (e.g. DATABASE_URL). Starting with digits or hyphens is invalid in POSIX shells.
Use double quotes ("...") for values containing spaces, newlines (\n), or hash symbols. Single quotes preserve literal strings without escape expansion.
Lines beginning with # and blank whitespace lines are treated as non-executing comments. Inline comments require preceding whitespace ( #).
3. Runtime Compatibility Profiles: Dotenv, Node.js, Next.js & Docker
Because no single universally enforced specification exists for .env files, ToolMono provides four dedicated compatibility profiles:
De facto cross-platform standard. Supports multiline double/single quotes, escape expansion (\n), inline comments, and ${VAR} expansion.
Native Node.js CLI loader (node --env-file=.env). Does not interpolate variables natively ($VAR is literal). Single-line quoting only.
Enforces client vs server boundaries. Variables with NEXT_PUBLIC_ are embedded into client JavaScript bundles; server-only secrets must never use this prefix.
Evaluates Compose interpolation syntax including default fallbacks (${VAR:-default}) and mandatory checks (${VAR:?error}). Literal dollars are escaped as $$.
4. How to Validate a .env File Online
Follow these steps to validate your environment configuration:
- Select Workflow: Choose 1. Validate .env, 2. Compare .env Files, or 3. .env vs .env.example.
- Choose Profile: Select your runtime profile (Standard Dotenv, Node.js Native, Next.js, or Docker Compose).
- Paste or Upload: Paste your raw
.envtext or click Upload File. - Review Health Score: Check your Environment Health Score (0–100) and review syntax errors, duplicates, and empty variables.
- Inspect & Fix: Click View Line on any diagnostic card to jump directly to that line in the Monaco editor.
- Mask or Reveal: Toggle Reveal Secrets to safely inspect masked sensitive credentials in your current browser session.
5. How to Compare Two .env Files (Dev vs. Staging vs. Prod)
When deploying software across multiple lifecycle stages, configuration values inevitably diverge. In Compare Mode, ToolMono evaluates:
- Added Variables: Keys present in Environment B (e.g. Production) that do not exist in Environment A.
- Removed Variables: Deprecated keys lingering in Environment A that are missing in Environment B.
- Changed Variables: Keys present in both environments whose assigned values differ (with secret values masked).
- Key-Set Parity (%): Percentage of unique keys shared between both environments.
- Full Value Parity (%): Percentage of keys having identical assigned values.
6. Auditing .env Against .env.example
Team projects typically maintain a .env.example file in Git to document all expected keys. If a developer introduces a new variable (such as STRIPE_WEBHOOK_SECRET) without adding it to the template or production environment, the deployed application may crash on startup. Auditing against .env.example catches missing keys instantly while respecting optional variable tags.
7. Duplicate Key Line Rosters & Runtime Resolution
Duplicate variable keys (e.g. defining PORT=3000 on line 2 and PORT=8080 on line 24) cause unpredictable runtime behavior depending on whether your loader overrides or preserves first occurrences.
ToolMono tracks all duplicate declarations in a Line Roster, displaying the primary declaration line alongside all subsequent redeclarations, and discloses runtime resolution semantics according to your selected profile.
8. Empty Value Handling & Quoting Diagnostics
Variables defined with empty values (API_KEY=) can lead to silent authentication failures in downstream SDKs. ToolMono flags empty variables as configurable warnings or errors and warns when unquoted values contain spaces that could truncate strings in shell environments.
9. Secret Detection Heuristics & Automatic Masking
Distinguishes high-confidence token patterns (AWS access keys, JWTs, Stripe keys, GitHub PATs, PEM private keys) from heuristic variable names (PASSWORD, SECRET, KEY).
All detected secrets are masked with bullets (sk_live••••••••••••) in the UI, diff views, and export reports, preventing accidental screen sharing leaks.
10. Variable Interpolation & Circular Reference Detection
Modern configurations frequently reuse values via variable expansion (e.g. API_URL=https://${HOST}:${PORT}/v1). ToolMono's safe in-memory graph expansion handles variable interpolation without evaluating arbitrary shell scripts:
- Circular Reference Protection: Identifies cycles (
A=${B},B=${A}) and flags errors before infinite loops occur. - Docker Fallbacks: Evaluates default fallback expressions (
${PORT:-3000}) and mandatory variable assertions (${DB_PASS:?required}). - Literal Quoting: Values wrapped in single quotes are preserved literally without interpolation expansion.
11. Configuration Drift & Parity Scoring
Environment Parity measures the degree of alignment between two configuration sets. ToolMono calculates parity deterministically:
Key-Set Parity = (Shared Keys / Total Unique Keys) * 100 Full Value Parity = (Unchanged Key-Value Pairs / Total Unique Keys) * 100
13. Step-by-Step Practical Comparison Example
Comparing Development vs Production configurations:
PORT=3000 NODE_ENV=development API_URL=https://dev.api.com DEBUG=true
PORT=3000 NODE_ENV=production API_URL=https://api.com SENTRY_DSN=https://sentry.io
Comparison Result:
ADDED:SENTRY_DSNis configured only in Production.REMOVED:DEBUGexists in Dev but is absent in Production.CHANGED:NODE_ENVandAPI_URLdiffer between environments.UNCHANGED:PORT=3000matches identically across environments.
14. Generating .env.example Templates & Sanitized Files
Creates a shareable template with empty values (KEY=) while preserving comments, headers, and structure.
Replaces detected secrets with REPLACE_ME, with an optional "Redact All Values" mode for high-security sharing.
15. Real-World DevOps & CI/CD Use Cases
Validate environment files before Docker build, Helm deployment, or Kubernetes rollout.
Ensure new developers have all required variables configured locally from .env.example.
Verify that no hardcoded production API keys or tokens are inadvertently committed to Git.
16. Exporting Markdown, JSON & CSV Reports
Export complete configuration reviews as structured JSON for automation pipelines, CSV summaries (with formula injection mitigation) for team spreadsheets, or formatted Markdown for GitHub pull request summaries.
17. 100% Client-Side In-Browser Privacy Guarantee
All .env parsing, duplicate detection, comparison algorithms, secret masking, and report generators run entirely within your local browser memory using JavaScript. No environment variables, passwords, or secret tokens are ever transmitted to ToolMono servers or third-party APIs.
18. Authoritative References & Specifications
Consult official documentation and standards on environment variables:
The Twelve-Factor App: III. Config
Authoritative methodology for storing configuration in the environment.
Motdotla Dotenv Specification & Repository
De facto reference standard for .env syntax and parsing conventions.
POSIX IEEE Std 1003.1: Environment Variables Specification
Official standard for operating system environment variable definitions and naming.
OWASP Secrets Management Cheat Sheet
Industry security standards for preventing credential leakage in configuration.
19. Frequently Asked Questions (20 FAQs)
Related Tools
Browse all toolsJSON Formatter
Free online JSON formatter, beautifier, and validator. Format, indent, minify, and inspect JSON with real-time syntax error detection in your browser. 100% client-side.
JSON Diff Checker
Compare two JSON files or objects online and find structural differences instantly. Detect added, removed, and modified values with nested key paths in your browser.
JSON Schema Validator
Validate JSON data against a JSON Schema online with detailed errors, JSON paths, draft detection, and browser-based processing.
OpenAPI Validator
Validate, lint, and audit OpenAPI 3.2, 3.1, 3.0 and Swagger 2.0 specifications in JSON or YAML. Detect syntax errors, broken $ref pointers, path issues, security vulnerabilities, and API design warnings in your browser.
GraphQL Playground
Test GraphQL APIs online with an interactive query editor, variables, headers, schema introspection, documentation explorer, response viewer, and GraphQL error debugging.
Webhook Tester
Generate a temporary webhook URL to capture, inspect, and debug incoming HTTP payloads, headers, and JSON in real time. Verify HMAC signatures instantly.
cURL to Code
Convert cURL commands into code for Python, JavaScript, Node.js, Go and PHP. Preserve headers, auth, cookies, and JSON bodies with ToolMono's free in-browser converter.