YAML to ENV Converter
Convert between YAML and .env file formats. Flatten nested YAML keys into environment variables or unflatten .env files into structured YAML.
About This Tool
The YAML to ENV Converter is a free, browser-based tool that
transforms data between YAML configuration files and
.env environment variable files. Whether you are
deploying an application with Docker, configuring a CI/CD
pipeline, or migrating settings between different configuration
formats, this tool streamlines the conversion process.
YAML is a popular format for application configuration,
particularly in Kubernetes manifests, Docker Compose files, and
frameworks like Spring Boot and Rails. Environment variables
stored in .env files are the standard for
twelve-factor app configuration and are supported by virtually
every deployment platform including Docker, Heroku, Vercel,
and AWS.
When converting YAML to ENV, the tool recursively flattens
nested YAML structures into flat key-value pairs. For example,
a nested key like database.host becomes
DATABASE_HOST in the environment file. You can
customize the key separator (underscore, double underscore, or
dot), choose the key case (uppercase, lowercase, or preserve),
and select how arrays are handled (comma-separated values or
indexed keys).
The reverse direction — ENV to YAML — parses
KEY=value lines, handles quoted values and
comments, and unflattens the keys back into a nested YAML
structure. This is particularly useful when you want to
visualize the hierarchical structure of a large set of
environment variables, or when porting an .env
configuration to a YAML-based system.
All processing happens entirely in your browser. No data is sent to any server, making it safe to convert files containing secrets, API keys, database credentials, and other sensitive configuration values.
How to Use
- Select the conversion direction: YAML → ENV or ENV → YAML using the toggle at the top.
- Paste or type your data into the Input panel on the left. Alternatively, click Sample to load example data.
- The converted output appears instantly in the Output panel on the right (when auto-convert is enabled).
- Adjust conversion options: key case (UPPERCASE, lowercase, or preserve), key separator (
_,__, or.), and array handling mode. - Toggle Quote all values to wrap every ENV value in double quotes, useful for values with special characters.
- Click Copy to copy the output, or use Ctrl+Shift+C .
- Use the Swap button to reverse the direction and move the current output into the input for round-trip conversions.
Popular YAML ↔ ENV Examples
FAQ
Is my data sent to a server?
No. All conversion is performed entirely in your browser using JavaScript. Your data never leaves your machine. There are no network requests, no logging, and no third-party services involved. It is safe to convert files containing secrets and credentials.
How does nested YAML get flattened into ENV keys?
Nested YAML keys are joined with the selected separator. For example, database: host: localhost becomes DATABASE_HOST=localhost when using the underscore separator with uppercase keys. You can change the separator to double underscore (__) or dot (.) depending on your needs.
How are YAML arrays handled?
You can choose between two modes. Comma-separated joins array items into a single value (e.g., FEATURES=auth,logging,metrics). Indexed keys creates a separate variable for each item (e.g., FEATURES_0=auth, FEATURES_1=logging). Choose whichever format your application framework expects.
Can I convert ENV back to nested YAML?
Yes. Switch to ENV -> YAML mode. The tool splits each key by the selected separator and reconstructs the nested YAML hierarchy. For best results, make sure the separator in the options matches the one used in your ENV keys.
What YAML features are supported?
The built-in parser handles the most common YAML subset: key-value pairs, nested objects via indentation, arrays (both block - item and inline [a, b, c] syntax), quoted strings, comments, and boolean/null/number detection. Advanced YAML features like anchors, aliases, and multi-line strings are not supported.
Why would I use double underscore as a separator?
Some frameworks and tools (notably .NET and Docker) use double underscores (__) to represent nested configuration hierarchy in environment variables. If your keys themselves contain underscores (e.g., my_app), using __ as the nesting separator prevents ambiguity when unflattening back to YAML.
What keyboard shortcuts are available?
Press Ctrl+Enter to run the conversion manually (useful when auto-convert is off). Press Ctrl+Shift+C to copy the converted output to your clipboard.
Related Tools
JSON ↔ YAML Converter
Convert between JSON and YAML formats instantly with syntax validation.
YAML Formatter
Format, validate, and minify YAML with customizable indentation and syntax error display.
TOML ↔ JSON Converter
Convert between TOML and JSON formats instantly. Perfect for Cargo.toml, pyproject.toml, and config files.
CSV ↔ JSON Converter
Convert between CSV and JSON formats with delimiter selection, header toggle, and file drag-and-drop.
Properties ↔ JSON Converter
Convert Java .properties files to JSON and back. Supports dot-notation expansion, Unicode escapes, multi-line values, and comments.