Configuration File

dotenv-diff supports a configuration file named dotenv-diff.config.json that allows you to persist your preferred flags. This makes it easier to share consistent settings between local development, teams, and CI/CD environments.

File Location

By default, dotenv-diff automatically looks for a dotenv-diff.config.json file in your project root (same folder as package.json).

You can quickly create one with the --init flag:

Terminal
dotenv-diff --init

⚙️ Example Configuration

dotenv-diff.config.json
{
  "strict": false,
  "example": ".env.example",
  "ignore": [
    "NODE_ENV",
    "VITE_MODE"
  ],
  "ignoreUrls": [
    "https://example.com"
  ]
}

This configuration defines default behavior across comparisons, scanning, and output. Every field corresponds to an equivalent CLI flag — meaning you can use dotenv-diff entirely from configuration without passing command line options.

Supported Options

OptionTypeDescriptionEquivalent CLI Flag
checkValuesbooleanCompare actual values if example has values.--check-values
cibooleanRun non-interactively and never create files.--ci
yesbooleanAutomatically answer “Yes” to prompts.--yes
envstringPath to a specific .env file.--env <file>
examplestringPath to your .env.example file.--example <file>
allowDuplicatesbooleanDo not warn about duplicate keys in .env files.--allow-duplicates
ignorestring[]List of keys to ignore during comparison or scanning.--ignore
ignoreRegexstring[]Regex patterns to skip matching keys.--ignore-regex
fixbooleanAutomatically fix issues (add missing keys, remove duplicates).--fix
jsonbooleanOutput results in JSON format.--json
noColorbooleanDisable colored terminal output.--no-color
onlystring[]Only run specific categories: missing, extra, empty, mismatch, duplicate, gitignore.--only
scanUsagebooleanScan codebase for environment variable usage.--scan-usage
comparebooleanCompare .env and .env.example files.--compare
includeFilesstring[]Additional file patterns to include in scan.--include-files
filesstring[]Override default file patterns (replaces built-in ones).--files
excludeFilesstring[]File patterns to exclude from scanning.--exclude-files
showUnusedbooleanShow variables defined in .env but unused in code.--no-show-unused
showStatsbooleanDisplay statistics summary at the end of scan.--no-show-stats
strictbooleanEnable fail-on-warning behavior.--strict
secretsbooleanEnable or disable secret detection.--no-secrets
ignoreUrlsstring[]URLs to skip in secret detection.--ignore-urls
noComparebooleanRun scan without comparing against any .env files.--no-compare

Behavior Notes

  • All options are optional; dotenv-diff uses sensible defaults when omitted.
  • CLI flags always take precedence over configuration values.
  • 🧩 Loaded dotenv-diff.config.json when a config file is detected.
  • The file must be valid JSON