TOML to ENV Converter
Flatten TOML configs into .env lines with shell-safe values.
TOML input
.env output
No .env output yet
Paste TOML or load an example.
Examples
Nested tables
[server.redis]
host = "cache.local"SERVER_REDIS_HOST=cache.localEvery table level becomes part of the environment variable name.
Array of tables
[[servers]]
host = "a"
[[servers]]
host = "b"SERVERS="[{\"host\":\"a\"},{\"host\":\"b\"}]"A structure env cannot express is serialized as one JSON string with a visible note.
Secret value
api_key = "sk$1 `whoami`"API_KEY="sk\$1 \`whoami\`"Shell metacharacters are escaped so sourcing the .env cannot execute them or expand variables.
About this tool
Twelve-factor deployments want flat environment variables; TOML configurations are nested. This converter walks a TOML table tree and emits one KEY=value line per leaf, joining table paths with underscores and uppercasing them by default. A dotted-key mode keeps the original casing and separators when your platform expects names such as APP_server.host.
The parser covers the everyday TOML surface: tables, dotted keys, quoted keys, arrays of tables, basic and literal strings (including multiline forms), integers with separators and bases, floats, booleans, datetimes, arrays and inline tables. Document order is preserved, so the generated .env reads like the source config.
Values are stringified with care. Booleans and numbers stay bare, datetimes are quoted, arrays and inline tables become compact JSON strings, and strings with spaces or shell metacharacters are double-quoted with backslash escapes for backslash, double quote, dollar and backtick. Three quote policies let you force or forbid quoting when a different consumer expects it.
Arrays of tables are the one structural compromise: env has no nested type, so each array becomes a single JSON line and the interface says so. Collisions after flattening are reported rather than silently overwritten. All conversion happens in this tab — configs often contain credentials and are never uploaded.
What this tool does not do
- The parser covers the practical TOML subset described above, not every corner of TOML 1.0 (for example, deeply nested array-of-table headers).
- Env variables cannot express nesting; arrays of tables and inline tables become JSON strings.
- Escaping is tuned for shell and dotenv-npm; other consumers may interpret backslashes differently.
- Config content stays in the browser and is never persisted, so reload the page to start over.
How to use this tool
Paste TOML
Paste a config file or load the database or nested-table example.
Choose key and quote policies
Pick SCREAMING_SNAKE or dotted keys, an optional prefix, and auto, all or never quoting.
Review notes
Read the structure notes for arrays of tables, comment preservation and any flattened key collisions.
Copy the .env
Copy the output or download it as .env, then review before sourcing it in a shell.
Use cases
Rust or Python config to 12-factor
Bridge Cargo.toml-adjacent or pyproject-style settings into the flat env variables your deployment platform expects.
Docker and CI env generation
Turn a checked-in TOML settings file into an env block for Compose, Kubernetes or CI secrets without hand conversion.
Generating .env.example
Use dotted keys and comment preservation as a starting point for documentation of a deployment's configuration surface.
Value mapping
| TOML value | .env output |
|---|---|
| [database] url = "…" | DATABASE_URL=… |
| port = 5432 / tls = true | PORT=5432 / TLS=true |
| tags = ["a", "b"] | TAGS="[\"a\",\"b\"]" |
| point = { x = 1 } | POINT="{\"x\":1}" |
| when = 1979-05-27T07:32:00Z | WHEN="1979-05-27T07:32:00Z" |
| key = "sk$1" | KEY="sk\$1" (shell-safe) |
Escaping targets shell export and dotenv-npm style consumers; docker --env-file uses different rules.
Common mistakes
Mistake:Sourcing generated env in Docker, which does not process backslash escapes.
Fix:The default escaping targets shell export and dotenv-npm. For docker --env-file or Compose, review the values and consider quote-all or a consumer-specific quoting pass.
Mistake:Assuming arrays remain arrays in the environment.
Fix:Environment values are strings. Arrays and inline tables are emitted as compact JSON and must be parsed by the consuming application.
Mistake:Ignoring collision notes.
Fix:Two TOML paths can flatten to the same env key. The last value wins and the note lists the key — rename one path if both are needed.
Frequently asked questions
How are nested tables flattened?
Every table level is appended to the variable name. In the default SCREAMING_SNAKE mode [server.redis] host becomes SERVER_REDIS_HOST; in dotted mode it becomes server.redis.host. An optional prefix is added in front of either form.
How do arrays and inline tables export?
Environment variables are strings, so arrays and inline tables are serialized as compact JSON and then quoted. A note appears whenever an array of tables is present to remind you that the consuming app must parse that JSON string.
Are values quoted?
Auto mode leaves simple values bare and double-quotes anything with spaces or shell metacharacters, escaping backslash, double quote, dollar and backtick. Quote all and never-quote policies are available when your consumer has different rules; review the output before sourcing it.
What happens to dates and times?
TOML date, datetime and time values are emitted as quoted ISO-8601 strings, since a bare value with colons and a leading digit is not a valid shell identifier. Local date/time forms keep their original textual form.
Can I keep comments from the TOML file?
Yes. Comment lines are emitted as # lines with their original line numbers when Keep comments is on; turn it off for a purely machine-readable .env. Inline comments are detected but not carried into values.
Is my config uploaded?
No. Parsing, flattening and quoting all run in this browser tab. Config files often contain credentials, so nothing is transmitted or stored.
References & standards
Related tools
Base32 Encoder / Decoder
Encode and decode Base32 (RFC 4648) with hex input mode and Crockford variant. Handles TOTP secrets. Runs in-browser.
Base58 Encoder / Decoder
Convert hex or text to Base58 and back, with Base58Check validation (version byte + checksum). IPFS CIDs too. In-browser.
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
BibTeX to JSON Converter
Parse .bib bibliographies into structured JSON with authors, months, macros and LaTeX cleanup, all in-browser.
C# to VB.NET Converter
Convert a subset of C# — classes, methods, variables, loops — into VB.NET
CSV Data Viewer
Paste CSV and inspect it as a sortable, searchable table with delimiter detection and inline export.