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

.env to TOML Converter

updated 24 May 2026

Turn a .env file into a structured TOML configuration. DATABASE__HOST=localhost becomes [database] host = "localhost". Booleans and numbers are coerced; quoted values are unwrapped.

keys become lowercase TOML identifiers

When to use it

You've been running a service from a .env file for a while. Now you want to commit a real configuration schema to the repo, with comments, types, and structure. This converter gets you 90% of the way there.

How to use it

  1. Paste your .env file on the left.
  2. Click Convert.
  3. Review and clean up the TOML — most edits will be adding comments and grouping related keys.

Mapping rules

  • Lines starting with # are treated as comments and skipped.
  • export VAR=value is accepted; the export prefix is stripped.
  • Quoted values ("...", '...') are unwrapped; backslash escapes are unescaped.
  • true / false become real booleans; pure-numeric values become integers or floats.
  • Keys with __ (double underscore) are split into nested tables: DB__HOST[db] host = ….
  • Output keys are lowercased and emitted as canonical TOML 1.0.

FAQ

What if my keys use single underscores for nesting?

The converter treats single _ as part of the key name. If you want to nest, switch the separator to __ before converting, or post-process the TOML in your editor.

Are array values supported?

No. .env has no array syntax. Values like TAGS=a,b,c come through as strings. Edit the TOML to wrap them in [ ] after conversion.

Will it preserve my comments?

No. Comments are parsed only to be skipped — they don't carry into the TOML tree. Add them back manually in the output.