FOSSA Logo

Environment Variable Formatter

Convert environment variables between different formats for your deployment environments.

About Environment Variables

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are used to configure applications and are widely used in DevOps workflows for managing different environments, configurations, and secrets.

Common Formats

.env Files

The most common format for environment variables. Each line contains a key-value pair separated by an equals sign. Comments start with #.

# Database settings
DB_HOST=localhost
DB_PORT=5432

Docker Compose

In Docker Compose files, environment variables are specified under the "environment" section for each service.

version: '3'
services:
  app:
    environment:
      - DB_HOST=localhost
      - DB_PORT=5432

Kubernetes Secrets

In Kubernetes, sensitive information is stored as Secrets. Values are Base64 encoded.

apiVersion: v1
kind: Secret
metadata:
  name: database-credentials
type: Opaque
data:
  DB_HOST: bG9jYWxob3N0
  DB_PORT: NTQzMg==

Shell Export Commands

Shell scripts often set environment variables using the export command.

#!/bin/bash
export DB_HOST="localhost"
export DB_PORT="5432"
export API_KEY="secret-key"

Best Practices

  • Never commit secrets to version control. Use a secret management tool instead.
  • Use consistent naming for environment variables, typically UPPERCASE with underscores.
  • Group related variables with common prefixes (DB_*, API_*, etc).
  • Provide default values in your application code for non-critical configuration.
  • Document all variables used by your application for easier onboarding.
  • Validate environment variables at application startup to fail fast if required variables are missing.

Get started with FOSSA

Start managing your dependencies, licenses, and vulnerabilities today.