Dotenv to YAML Converter

Convert .env files to YAML format with nested key support

What is Dotenv to YAML Converter?

A .env (dotenv) file stores environment variables in flat KEY=VALUE format, commonly used in Node.js, Python, and other frameworks. This tool converts those variables into structured YAML, supporting nested keys via separator splitting. YAML is widely used in Docker Compose, Kubernetes, CI/CD pipelines, and many configuration systems.

How to Use

  1. Paste your .env file content in the left panel
  2. Choose a key separator: underscore (_) splits DB_HOST into db > host, double underscore (__) only splits on __
  3. Choose key case: lowercase converts keys to snake_case YAML, uppercase keeps them upper, preserve keeps original
  4. Click Convert to generate the YAML output
  5. Copy the YAML result or use it in your configuration

Why Use This Tool?

Convert .env files for Docker Compose and Kubernetes configs
Group flat environment variables into hierarchical YAML structure
Migrate from dotenv to YAML-based configuration systems
Supports nested keys, comments, quoted values, and export prefix
All processing happens in your browser — no data sent to servers

Tips & Best Practices

  • Use underscore separator to group keys like DB_HOST, DB_PORT under a db parent
  • Use double underscore separator when your keys intentionally contain single underscores
  • Lines starting with # are treated as comments and skipped
  • The 'export' prefix (e.g., export KEY=value) is automatically removed
  • Boolean (true/false) and numeric values are output unquoted in YAML
  • Never commit .env files with real secrets to version control

Frequently Asked Questions

What is a .env file?

A .env file is a plain text file that stores environment variables in KEY=VALUE format. It is the standard way to configure applications in Node.js (via the dotenv package), Python, Ruby, and many other frameworks. Each line contains one variable assignment.

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, Kubernetes ConfigMaps, CI/CD pipelines, and any system that requires hierarchical configuration.

Are my secrets safe?

Yes. All processing happens in your browser. Your .env content is never sent to any server. However, always be careful when sharing .env files — use .env.example with placeholder values instead.

How does nested key grouping work?

When the underscore separator is selected, keys like DB_HOST and DB_PORT are split by underscore and grouped under a db parent key in YAML, producing db: host: localhost and db: port: 5432. With double underscore separator, only __ is treated as a nesting boundary.

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 (standard .env behavior).

Can I convert YAML back to .env?

Not with this tool, but you can manually flatten YAML keys by joining them with underscores and writing KEY=value on each line. We may add a reverse converter in the future.

Related Tools