Why Convert YAML to TOML?
Teams move from YAML to TOML when they want a config format that is harder to get wrong. YAML's significant whitespace and surprising type coercion (no becoming false, 1.10 becoming a number) cause real bugs. TOML's explicit, bracket-delimited tables remove the indentation ambiguity. The conversion is common when adopting Rust tooling, or simply standardizing a polyglot repo on one config style.
How Mappings and Sequences Translate
A YAML mapping becomes a TOML table; a YAML sequence becomes a TOML array. The direction reverses what we saw going TOML→YAML:
title: My App
database:
host: localhost
port: 5432
title = "My App"
[database]
host = "localhost"
port = 5432
A YAML list of maps becomes an array of tables:
steps:
- name: build
run: make
- name: test
run: make test
[[steps]]
name = "build"
run = "make"
[[steps]]
name = "test"
run = "make test"
What Has No TOML Equivalent
This direction is where conversions can lose information, because YAML has features TOML simply lacks:
- Anchors and aliases (
&anchor/*alias) — TOML has no reference mechanism. A converter must expand them, duplicating the referenced data inline. The result is correct but larger, and the de-duplication intent is lost. null— YAMLnull(or empty value) has no TOML type. These keys are typically dropped; decide whether that is acceptable.- Non-string keys — YAML allows numbers or even sequences as mapping keys. TOML keys are strings, so such keys must be stringified.
- Multiple documents — a single YAML file can hold several documents separated by
---. TOML has no such concept; convert one document at a time.
Multi-Line Strings
Both formats support multi-line strings, but with different syntax. YAML block scalars (| literal and > folded) map onto TOML's triple-quoted strings:
description: |
Line one
Line two
description = """
Line one
Line two
"""
A folded > scalar, which joins lines with spaces, is converted to its already-folded single-line form before being written.
A Safe Conversion Workflow
- Resolve or remove anchors/aliases mentally — know that they will be expanded.
- Convert one YAML document at a time.
- Check that no meaningful
nullkeys were silently dropped. - Validate the TOML with a parser before committing.
Frequently Asked Questions
Does YAML-to-TOML lose data? It can. Anchors/aliases are expanded (losing the reference), nulls are dropped, and multi-document files must be split. Plain mappings, sequences, and scalars convert cleanly.
What happens to YAML anchors and aliases? TOML has no references, so the converter inlines the referenced content everywhere it was used. The data is preserved but duplicated.
Can I convert a multi-document YAML file?
Not in one pass — TOML has no document separator. Convert each --- section into its own TOML file.
Paste your YAML into the converter above to get valid TOML, with anchors expanded and tables generated automatically.