# 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.

```yaml
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.

```yaml
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.

```bash
#!/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.
