Skip to main content

Environment Variable

PropertyValue
descriptionNamed value provided to a process or runtime environment to configure software behavior without hardcoding it into source code.
tagsref

An environment variable is a named value provided to a process or runtime environment to configure software behavior without hardcoding it into source code.

Environment variables are one of the most common ways to pass configuration into applications and scripts.

What it does

Environment variables let software read configuration from the environment it is running in.

It is commonly used to:

  • Configure apps without changing source code
  • Provide credentials or connection details
  • Set runtime behavior per environment
  • Pass values into scripts, CLIs, and services
  • Differentiate development, staging, and production settings

Core concepts

Name-value configuration

An environment variable is usually a key-value pair available to a process.

The program reads that value at runtime.

Runtime-level config

Environment variables are part of the runtime environment rather than the code itself.

That makes them useful for deployment and system-level configuration.

Common in modern app workflows

Environment variables are especially common in web apps, containers, CI systems, and deployment platforms.

They are one of the standard ways to externalize configuration.

Common use cases

  • API keys
  • Database URLs
  • Feature flags
  • Port and host settings
  • Service credentials

Practical notes

  • Environment variables are simple and flexible, but they still need secure handling.
  • Sensitive values in environment variables should be treated like secrets.
  • .env files are a common local-development pattern for loading environment variables.
  • Environment variables are closely related to deployment, runtime, and infrastructure workflows.

Sources Used

Frequently Asked Questions

Is an environment variable the same as a .env file?

No. A .env file is one common way to define environment variables, especially in local development.

Should secrets be stored in environment variables?

Often yes, but they still need careful handling and may be better managed through dedicated secret systems in some environments.

Why use environment variables?

Because they let you change configuration without editing source code.