YAML ↔ TOML Converter Online

Convert YAML to TOML and TOML to YAML instantly in your browser.

INPUT — YAML
OUTPUT — TOML

When a YAML ↔ TOML converter is the right tool

Use this page to move a configuration mapping between YAML and TOML — for example when a project prefers Cargo.toml or a tool expects a YAML file. Choose a direction, paste a single document, and click Convert. The YAML root has to be a mapping, not a list. The result does not update as you type.

This is a data converter. Comments, exact number formatting, and the original layout are not preserved. If you need JSON in the middle, use TOML ↔ JSON or JSON ↔ YAML.

Use cases

Turning a YAML service config into TOML

Leave the direction on YAML → TOML and Load Sample for a short database, credentials, server, and features document. Nested mappings become TOML tables such as [database.credentials]. A root-level list becomes a TOML array.

Turning TOML back into YAML

Switch to TOML → YAML and paste a TOML table. Load Sample in this direction is not a mirror of the YAML sample: its features array sits under [server], so the YAML you get will nest features under server.

Checking a date or a port number

A YAML date may come out as a TOML offset datetime with a .000Z suffix. A port such as 5432 may be written 5_432. Both are valid in TOML; they just will not look like the source.

How conversion works

YAML → TOML calls yaml.load, rejects a non-object root, and passes the object to TOML.stringify. Root keys that are arrays often appear first in the TOML, followed by table sections; nested tables may be indented. TOML → YAML parses with @iarna/toml and dumps with js-yaml. Switching direction clears both editors. There is no Swap button.

Example — a YAML mapping becomes TOML, with a grouped port and a root array first
database:
  host: localhost
  port: 5432
  credentials:
    user: admin
    password: secret
features:
  - auth
  - logging

features = [ "auth", "logging" ]

[database]
host = "localhost"
port = 5_432

  [database.credentials]
  user = "admin"
  password = "secret"

5_432 is still the integer 5432. The credentials table is written as a subsection under [database]. That layout comes from @iarna/toml, not from an indent control on this page.

What this tool does not do

It does not convert a YAML document whose root is a list, keep comments or anchors, or preserve the sample documents as a faithful pair. It does not update live, and it does not upload anything. Pretty-print the YAML afterwards with YAML Formatter, or compare two versions with YAML Diff or TOML Diff.

How to use YAML ↔ TOML Converter

  1. Choose YAML → TOML or TOML → YAML. Switching tabs clears the input.
  2. Paste a single document, or use Load Sample for an example in the current direction.
  3. Click Convert, then Copy when the output looks right.
  4. Use Clear to empty both editors.

Frequently asked questions

How does the conversion work?

YAML → TOML loads the input with js-yaml, requires the root to be a mapping object, and writes TOML with @iarna/toml. TOML → YAML parses with @iarna/toml and dumps YAML with js-yaml at indent 2 and no line wrapping. You have to click Convert; the output is not computed as you type.

Why is a YAML list at the root rejected?

TOML’s document root must be a table. If the YAML root is a sequence, a scalar, or null, the tool throws “YAML root must be a mapping object for TOML conversion.” Arrays are fine as values under a key. A multi-document YAML stream is also rejected, because js-yaml load expects a single document.

Are the Load Sample documents equivalent in both directions?

No. The YAML sample puts features at the root. The TOML sample places features = [...] under the [server] table, because in TOML a key after a table header belongs to that table. Converting the YAML sample produces a root-level features array; converting the TOML sample nests features under server. Treat each sample as an example of its own format, not as a round-trip pair.

What happens to comments, dates, and numbers?

Comments are dropped in both directions. A YAML timestamp such as 2020-01-01 is parsed by js-yaml as a Date and written as a TOML datetime 2020-01-01T00:00:00.000Z. Integers may be written with underscores, so 5432 can appear as 5_432 — that is still valid TOML. A YAML 1.0 becomes the number 1. Layout, including inline tables versus dotted headers, is not preserved.

Do the results update as I type? Is there a Swap button?

No. You have to click Convert. Switching YAML → TOML or TOML → YAML clears the input and the output. There is no Swap control and no indent option. Load Sample pastes an example for the current direction and clears the output.

Is my data sent to a server?

No. Conversion runs in your browser with js-yaml and @iarna/toml. Closing the tab discards what you pasted. Do not paste configuration that contains secrets if you would not be comfortable with it sitting in memory on this device.

Related tools and guides

References

  • TOML v1.0.0 requires the document root to be a table, which is why a YAML list at the root cannot be converted here. Output is written with @iarna/toml.
  • YAML 1.2 is the language js-yaml targets. This page loads a single document and, in the TOML → YAML direction, dumps with indent 2.