YAML to TOML Format — Numio
Converts one YAML document to TOML. Nested mappings become [table.sub] sections, lists of mappings become [[array of tables]], and keys with null (~) values are dropped.
Rewriting a YAML config as TOML when a project moves to pyproject.toml, Cargo, Hugo or Netlify TOML settings.
YAML
TOML
When to use it
- Rewriting a YAML config as TOML when a project moves to pyproject.toml, Cargo, Hugo or Netlify TOML settings.
- Checking how a nested YAML structure would look as TOML tables before choosing a config format.
How to use
- Paste a single YAML document with a mapping at the top level into the left editor, or use the load-file button to open a UTF-8 file.
- Fix any reported YAML error (indentation, multiple documents, or a top-level list).
- Check dates, nulls and lists in the TOML, then copy it.
YAML
# docker-compose style
version: "3.9"
services:
web:
image: nginx:1.27
ports:
- "8080:80"
environment:
DEBUG: false
WORKERS: 4
db:
image: postgres:16TOML
version = "3.9" [services.web] image = "nginx:1.27" ports = [ "8080:80" ] [services.web.environment] DEBUG = false WORKERS = 4 [services.db] image = "postgres:16"
Details and limitations
YAML is read as YAML 1.2: yes stays the string "yes", 0o17 becomes 15, and unquoted dates like 2024-01-05 become TOML strings, not TOML dates.
Comments and anchors are not kept as such: aliases (*name) and <<: *anchor merge keys are expanded into the values they refer to.
Only one document is accepted; input with --- separators fails with a multiple-documents error. A top-level list, or a list mixing mappings with plain values, is rejected with an explanation.
Runs in your browser (yaml + @iarna/toml). Sub-tables such as [services.web.environment] are indented by two spaces; TOML ignores this indentation.
FAQ
Can I convert a docker-compose.yml to TOML?
The structure converts, as in the example, but Docker Compose only reads YAML. Use this to inspect or reuse the data, not as a Compose file.
What happens to null values?
Keys whose value is ~ or null are omitted because TOML has no null type.
Are YAML anchors and merge keys supported?
Yes. Aliases (*name) are expanded, and <<: *base copies the keys of base into the mapping, with keys written next to it taking precedence. The TOML shows the merged values.