dotenv-expand is a zero-dependency module that extends dotenv with advanced environment-variable processing. It expands variables inside .env values using braced or unbraced interpolation syntax. Default values and alternate-value expressions allow configuration to adapt when variables are present or missing. The package also supports command substitution, allowing trusted .env files to insert the output of local commands. Encrypted values created with dotenvx can be decrypted when the required private key is supplied separately. Developers can preload the module before an application starts or expand parsed values programmatically into process.env or a custom object. Version 12 and later no longer expand variables that already exist in process.env, making the behavior more predictable.
Features
- Environment variable interpolation
- Braced and unbraced expansion syntax
- Default and alternate value expressions
- Trusted command substitution
- Encrypted dotenvx value support
- Preload and programmatic expansion modes