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://...Outputprocess.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
dotenv
dotenv is the library and convention that loads .env files into environment variables; it is the most popular in the Node.js ecosystem and externalizes configuration. GLOSSARY
INI
INI is a traditional configuration file format that groups settings with [section] headers and key=value pairs; it is simple but unstandardized, and implementations differ slightly. GLOSSARY
Properties
Java Properties files use KEY=VALUE or KEY:VALUE format; they are the traditional configuration format of the Java ecosystem and support Unicode escapes. GLOSSARY
YAML
YAML (YAML Ain't Markup Language) is a configuration-oriented data serialization format using indentation for hierarchy, supporting comments and references, and better suited to hand editing than JSON. GLOSSARY