Skip to content
uencoder

ENV

An ENV file defines environment variables in KEY=VALUE format for application configuration; it is the recommended approach of 12-factor apps.

Purpose

To provide the standard way of injecting configuration through environment variables, separating configuration from code.

Mechanism

Each line is KEY=VALUE; # marks comments and blank lines are ignored. Values usually carry no quotes (quote them when they contain spaces). A shell or a dotenv library loads them into process.env. No types (all strings) and no nesting.

Use cases

  • Node.js .env configuration
  • Docker container environment variables
  • CI/CD secret injection
  • Local development configuration

Examples

  • Input
    PORT=3000
    DB_URL=postgres://...
    Output
    process.env.PORT="3000"

    Everything is a string

Common errors

Committing .env to version control leaks secrets
Add it to .gitignore and provide a .env.example template

Related terms

References