Convert TOML to Environment Variables - Complete Guide
Input Your TOML Configuration
Get your TOML configuration ready. You have a few options:
.toml fileTOML input example:
[database] host = "localhost" port = 5432 enabled = true
Read the Generated .env
The output appears as soon as you type. Here is how it maps TOML onto environment variables:
DATABASE_HOSTTAGS_0, TAGS_1$(...) or expands $HOMEENV output example:
DATABASE_HOST=localhost DATABASE_PORT=5432 DATABASE_ENABLED=true
Copy or Download
Copy the lines straight into your clipboard, or download them as a converted.env file for a Docker container, a Kubernetes deployment, or a local dotenv setup. Everything runs in your browser; the TOML is never uploaded, and reloading the page starts you with an empty editor.
FAQs About TOML to ENV Conversion
Why turn a TOML file into environment variables?
Environment variables are how most containers are configured — Docker Compose reads them from an env_file, Kubernetes puts them in a ConfigMap, and the 12-factor approach keeps config out of the code. If your settings live in a TOML file, this flattens them into the KEY=VALUE lines those tools expect.
How are nested TOML tables flattened?
Each level of the path becomes part of an uppercase, underscore-joined name. [database.credentials] with username = "admin" becomes DATABASE_CREDENTIALS_USERNAME=admin. An array of tables like [[services]] is numbered, so the first service’s name is SERVICES_0_NAME.
What happens to arrays?
Every item gets its own variable, numbered from zero: tags = ["a", "b c"] becomes TAGS_0=a and TAGS_1='b c'. Numbering each item keeps a value that contains a comma or a space from blurring into its neighbours, which a single comma-joined line would lose.
Is the output safe to source in a shell?
Yes. A value that isn’t plain letters and digits is wrapped in single quotes, so $(command), `backticks` and $HOME are written as text, not run or expanded. The same file also loads correctly with python-dotenv and Docker Compose. A rare value that holds both a single quote and a $ is escaped with a backslash, and a note points it out.
Will my numbers and dates change?
No. Long integers like 8901240544102066246, decimals written as 14.50, and strings such as "00501" come through exactly as typed, and dates stay as written. A hex integer such as 0x1F is written as its decimal value, 31.
What other TOML tools do you have?
There is TOML to JSON, TOML to YAML, TOML to XML, a TOML Formatter and a TOML Validator.
Related Tools
JSON to TOML
Convert JSON data to TOML configuration format for Rust and other projects
TOML to JSON
Convert TOML configuration files to JSON format with syntax validation
TOML Formatter
Format and beautify TOML configuration files with proper indentation
TOML Fixer
Fix broken TOML config files automatically, repair syntax errors, and validate TOML structure
TOML Validator
Validate TOML syntax and structure with error detection
YAML to TOML
Convert YAML configuration files to TOML format for Rust projects