T tomlkit·org
Inspect Formatter Validator Convert TOMLJSON JSONTOML TOMLYAML YAMLTOML INITOML TOMLINI .envTOML TOML.env TOMLTS Transform Sort keys Flatten Minify Compare Diff Merge

TOML to .env Converter

updated 24 May 2026

Flatten a TOML configuration into KEY=VALUE pairs suitable for a .env file, Docker Compose, Kubernetes ConfigMaps, or any 12-factor environment loader. Nested tables become double-underscore separators.

When to use it

Almost every container platform — Docker, Kubernetes, Heroku, Fly, Railway — expects configuration as environment variables. Keeping the authoritative config in TOML and emitting a .env at build time gives you the best of both: a hand-readable source of truth, and a deploy-ready artifact.

Frameworks like Spring Boot, .NET Configuration, and Symfony's DotenvVault already understand DATABASE__HOST as database.host. This converter follows that convention.

How to use it

  1. Paste TOML on the left.
  2. Click Convert.
  3. Copy the output into your .env file or pipe it into your CI's secret manager.

Naming convention

  • Keys are uppercased and any non-alphanumeric character becomes _.
  • Nested tables use __ (double underscore) as a separator. database.pool.sizeDATABASE__POOL__SIZE.
  • Arrays are joined with , (single comma, no spaces).
  • Strings with whitespace, quotes, $, or # are wrapped in double quotes with backslash escaping.
  • Booleans render as true / false; numbers and dates are emitted as their canonical string form.

FAQ

Why __ and not . as separator?

Most shells refuse . inside environment variable names. __ is the convention adopted by Spring Boot, .NET, and Helm.

Can I round-trip back to TOML?

Yes — use .env → TOML. The round trip is lossless for scalars; arrays come back as strings because .env has no array syntax.

Is it safe to put secrets through this?

The conversion runs entirely in your browser. Nothing is uploaded. That said, treat the output the way you'd treat any .env file — don't commit it.