Dotenv to YAML Converter

Convert .env files to YAML format with nested key support

What is Dotenv to YAML Converter?

Dotenv files (.env) store environment variables as flat KEY=VALUE pairs, which works well for simple applications but becomes unwieldy when configuration grows to include database settings, cache options, and feature flags all prefixed with DB_, REDIS_, or APP_. YAML supports hierarchical nesting, comments, and complex data types that flat .env files cannot express. This converter reads your .env file, splits keys by a configurable separator (underscore or double underscore) to create nested YAML structures, and applies your choice of key casing. The result is a clean, organized YAML file ready for Docker Compose, Kubernetes ConfigMaps, CI/CD pipelines, or any system that consumes YAML configuration.

How to Use

  1. Paste your .env file content into the left panel.
  2. Choose a key separator: single underscore (_) splits DB_HOST into db > host, while double underscore (__) only splits on double underscores.
  3. Choose key casing: lowercase converts all keys to snake_case, uppercase keeps them upper, and preserve maintains the original casing.
  4. Click 'Convert' to generate the YAML output with nested structure based on your separator choice.
  5. Copy the YAML result and use it in your Docker Compose file, Kubernetes ConfigMap, or CI/CD pipeline configuration.

Why Use This Tool?

Convert flat .env files into hierarchical YAML that groups related settings under parent keys
Migrate from dotenv to Docker Compose, Kubernetes ConfigMaps, or any YAML-based configuration system
Configurable separator and key casing give you control over the nesting depth and naming convention
Automatic type detection outputs booleans and numbers unquoted in YAML for proper type representation
Browser-only processing keeps your secrets private — nothing is uploaded or stored on any server

Tips & Best Practices

  • Use the single underscore separator to group related keys like DB_HOST, DB_PORT, DB_NAME under a db parent key.
  • Use the double underscore separator when your keys intentionally contain single underscores that should not be split.
  • Boolean values (true/false) and numeric values are output unquoted in YAML, which means YAML parsers will interpret them as their native types.
  • The 'export' prefix (e.g., export KEY=value) is automatically stripped from key names.
  • Never commit .env files with real secrets to version control — use .env.example with placeholder values instead.

Frequently Asked Questions

How does nested key grouping work?

When the underscore separator is selected, keys like DB_HOST and DB_PORT are split at each underscore and grouped into nested YAML. DB_HOST=localhost becomes db: host: localhost. With double underscore separator, only __ is treated as a nesting boundary, so DB_HOST stays as a single key while APP__DEBUG becomes app: debug.

When should I NOT use this converter?

Avoid this tool when your .env keys do not follow a consistent naming convention that can be split into groups — the resulting YAML may be harder to read than the original flat file. Also, if your .env uses variable interpolation (e.g., DATABASE_URL=${HOST}:${PORT}), the references will not be resolved during conversion.

Why convert .env to YAML?

YAML supports nested structures, comments, and complex data types that flat .env files cannot express. Converting .env to YAML is useful for Docker Compose environment sections, Kubernetes ConfigMaps, GitHub Actions workflow env blocks, and any system that requires hierarchical configuration.

What happens to comments?

Lines starting with # in the .env file are treated as comments and excluded from the YAML output. Inline comments after values are included as part of the value string, which matches standard .env behavior.

How are value types handled?

The converter detects boolean strings (true/false) and numeric strings and outputs them unquoted in YAML, so YAML parsers will interpret them as native booleans and numbers. All other values are output as strings, with quoting applied when necessary to prevent YAML misinterpretation.

Is my data sent to any server?

No. All parsing and conversion runs entirely in your browser. Your .env content and the generated YAML never leave your device. No data is collected, stored, or transmitted to any server.

Real-world Examples

Application Config to Nested YAML

Convert a typical application .env file into nested YAML for Docker Compose or Kubernetes.

Input
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp_production
APP_NAME=My Application
APP_ENV=production
APP_DEBUG=false
REDIS_URL=redis://localhost:6379
REDIS_TTL=3600
Output
db:
  host: localhost
  port: 5432
  name: myapp_production
app:
  name: My Application
  env: production
  debug: false
redis:
  url: redis://localhost:6379
  ttl: 3600

Feature Flags to YAML for ConfigMap

Convert feature flag environment variables into YAML for a Kubernetes ConfigMap.

Input
FEATURE_CACHE=true
FEATURE_LOGGING=false
FEATURE_DARK_MODE=true
FEATURE_BETA_UI=false
Output
feature:
  cache: true
  logging: false
  dark_mode: true
  beta_ui: false

Related Tools