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

YAML to TOML Converter

updated 8 June 2026

Paste YAML on the left, get TOML on the right. The entire conversion runs in your browser — nothing is uploaded.

YAML 1.2 → TOML 1.0 · types preserved

What this tool does

It loads a YAML document with js-yaml, then emits the resulting value tree as TOML 1.0. YAML mappings become tables, sequences of mappings become arrays-of-tables ([[servers]]), and scalars carry their types across — a YAML true stays a boolean, a number stays a number, a timestamp becomes a TOML datetime.

The intent it closes: "I have a YAML file and the project I'm dropping it into reads TOML." The usual destination is a Rust, Go, or Python project — a Cargo.toml, a Hugo/Zola config.toml, or any service that loads TOML at startup — where you'd rather not retype the hierarchy by hand.

Two structural rules to know up front: the YAML root must be a mapping (TOML has no top-level list), and TOML has no null — so the Nulls option decides what happens to YAML nulls rather than failing on them.

When you'd reach for it

  • Adopt a TOML config in a Rust or Go project. Convert an existing YAML settings file into the config.toml the project expects.
  • Migrate off YAML's whitespace sensitivity. TOML's explicit [headers] are harder to break than significant indentation.
  • Flatten a multi-document file. Keep only the first --- document, or wrap them all into one array — your choice via Multi-doc.
  • Drop YAML nulls cleanly. Leave Nulls on Drop and every null/~ key disappears instead of blocking the conversion.
  • Land a sorted, diff-stable file. Pick Alphabetical or Alpha, tables last for a tidy result regardless of YAML key order.
  • Convert credentials privately. Parsing and emission happen in your tab — a secrets file never leaves the machine.

How the conversion works

One click of Convert runs three stages.

1. Load the YAML

The document is parsed with js-yaml. Anchors (&name) and aliases (*name) are resolved during this step, so the value tree already contains real copies — TOML has no reference syntax, so each alias becomes a literal duplicate in the output. An empty document reports YAML document is empty. and a non-mapping root reports YAML root must be a mapping.

2. Apply multi-doc and null policy

If the file has several ----separated documents, Multi-doc chooses between keeping the first and wrapping them all under a documents array. Then the tree is walked for nulls, which are dropped or turned into "" per the Nulls option.

3. Emit TOML

The cleaned tree is written by the canonical TOML emitter, honouring Sort. Mappings become [table] headers, sequences of mappings become [[array-of-table]] blocks, and YAML timestamps emit as TOML offset datetimes.

Options reference

Nulls

Drop removes keys whose value is null (or YAML's ~) and strips nulls from sequences — the clean default, since TOML can't store a null. Empty string keeps the key and writes "" instead, for readers that need the key to exist.

Multi-doc

First only converts just the first document in a multi-document file and ignores the rest. Wrap as array loads every document and nests them under a top-level documents array-of-tables — useful when a single .yaml holds several manifests you want to keep together.

Sort

Preserve keeps YAML key order. Alphabetical sorts each table's keys A–Z. Alpha, tables last sorts A–Z but moves nested tables and arrays-of-tables below the scalars in every section.

Output and mapping rules

  • Mappings → tables. A YAML mapping becomes a [table] header (or dotted header when nested).
  • Sequences of mappings → arrays-of-tables. A YAML list of maps becomes repeated [[name]] blocks.
  • Sequences of scalars → inline arrays. A simple list becomes [1, 2, 3].
  • Anchors/aliases → literal copies. TOML has no references, so a *alias is written out in full wherever it was used.
  • Timestamps → TOML datetimes. A YAML timestamp parses to a date and emits as 1979-05-27T07:32:00Z.
  • Comments are not preserved — they aren't part of the parsed tree.
  • Download: output.toml, content type text/plain;charset=utf-8.

Example

Input (YAML):

title: "App Config"
database:
  enabled: true
  ports:
    - 5432
    - 5433
services:
  - name: "api"
    cpu: 2

Output (TOML):

title = "App Config"

[database]
enabled = true
ports = [5432, 5433]

[[services]]
name = "api"
cpu = 2

The services sequence of mappings becomes a TOML array of tables ([[services]]) — the idiomatic shape for a list of records.

Recipes by intent

Move a YAML config into a Rust/Go project

Convert with Nulls on Drop and Sort on Preserve, then save as config.toml. Any null placeholders from the YAML disappear so the file parses cleanly on first load.

Collapse a multi-manifest YAML

Set Multi-doc to Wrap as array. Every --- document lands under a single documents array-of-tables — one TOML file instead of several.

Produce a reproducible, sorted file

Pick Alpha, tables last. Scalars cluster at the top of every section and tables drop below, so the same YAML always yields the same TOML layout — clean diffs in version control.

Keep optional keys as blanks

Switch Nulls to Empty string when a TOML reader checks for a key's presence rather than its value; nulls become "" instead of vanishing.

Limits and performance

  • In-memory. Input, parsed tree, and TOML output all sit in memory at once. Config-sized files convert instantly; a very large YAML can hang the tab briefly while the TOML string is built.
  • Anchors are expanded, not preserved. A file that leans heavily on aliases to stay small will grow once they're written out as literals.
  • The textarea is the slow part on big output. Prefer Download .toml over Copy past tens of megabytes.
  • No streaming. A YAML file whose root is a giant sequence can't be a TOML root anyway — nest it under a key first.

Errors and how to fix them

YAML root must be a mapping.

Your YAML starts as a sequence (a - item list) or a bare scalar. TOML needs key-value pairs at the root, so nest the list under a key — items: followed by your list — and convert again.

YAML document is empty.

The input parsed to nothing — usually an all-comments file, or only --- separators with no content. Add at least one key-value pair.

A YAML parse error with a line number

The input isn't valid YAML — most often inconsistent indentation, a tab where spaces are required, or a missing space after a colon (key:value instead of key: value). The status bar reports where js-yaml stopped.

Some keys are missing from the TOML

Those keys held null (or ~) and Nulls is on Drop. Switch to Empty string to keep them as "".

Repeated blocks got written out twice

Your YAML used an anchor and alias to avoid repetition. TOML has no reference mechanism, so the aliased value is duplicated literally wherever it appeared — expected, not a bug.

FAQ

Does this handle YAML anchors and aliases?

Yes — they're resolved while loading. Because TOML can't express references, the data is duplicated wherever an alias was used.

Why can't a YAML list convert on its own?

TOML is a table at its core; there's no such thing as a TOML file that's just a list. Every value must belong to a key, so wrap a top-level list under one.

What versions are supported?

js-yaml reads YAML 1.2 and smol-toml emits TOML 1.0. Anything YAML can express but TOML can't — nulls, complex non-string keys — is handled by the Nulls option or rejected with a clear message.

Is my data uploaded?

No. There's no backend — conversion runs in your browser's JavaScript engine and your YAML never touches a log or third-party API.