What is an environment variable?

Definition

An environment variable lets an operating system, runtime, or hosting platform provide configuration when an application starts. Common uses include service endpoints, feature flags, environment names, and references to credentials that must differ between development, staging, and production.

Environment variables separate configuration from application code, but they are not automatically secure. Sensitive values still require restricted access, careful logging, rotation, and a hosting design that prevents them from being exposed to browsers or unauthorized processes.

ELI5

An environment variable is a named setting given to a program from outside its source code when the program runs. It lets development, testing and production use different endpoints, feature settings or credential references without rewriting the application.

For example, the same app can receive one database address on a laptop and another on its production server. Secret values still need protected storage and careful logging because putting a password in an environment variable does not automatically make it safe.

Acronyms and aliases

environment configuration variable variant

Frequently asked questions

Why use environment variables for application configuration?

They let the same code run with different deployment settings without embedding those values in the source or rebuilding the application.

Are environment variables a complete secret-management solution?

No. They reduce source-code exposure, but access controls, secret storage, log hygiene, rotation, and runtime isolation are still necessary.

Videos explaining environment variable