Convert TOML files with the TOML to YAML converter
This TOML to YAML converter parses TOML 1.0 with smol-toml and writes block-style YAML with js-yaml. It is useful when you move a project between ecosystems, for example taking settings from a Hugo config.toml into a Kubernetes or GitHub Actions workflow, or when you simply find YAML easier to scan than a long list of TOML tables.
Example
A Rust manifest:
[package]
name = "acme-cli"
version = "0.3.1"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = "1"
[profile.release]
lto = true
opt-level = 3
YAML output:
package:
name: acme-cli
version: 0.3.1
edition: '2021'
dependencies:
serde:
version: '1.0'
features:
- derive
tokio: '1'
profile:
release:
lto: true
opt-level: 3
Notice the quotes around '2021', '1.0' and '1'. They were strings in TOML, and without quotes YAML would read them as numbers, so the converter keeps their type explicit. 0.3.1 is not a valid number and needs no quotes.
How TOML types map to YAML
- Tables and dotted tables (
[profile.release]) become nested mappings. - Inline tables such as
{ version = "1.0" }become ordinary block mappings. - Arrays of tables (
[[databases]]) become a YAML list of mappings. - Multi-line strings (
'''…'''or"""…""") become YAML block scalars (|-). - Hex, octal and binary integers like
0xDEADBEEFare written in decimal (3735928559). infandnanbecome.infand.nan.
Dates and times
TOML has native date-time types, and they are written as YAML timestamps. An offset date-time like 1979-05-27T07:32:00-08:00 becomes 1979-05-27T07:32:00.000-08:00, and a plain date like 2021-04-01 stays unquoted. A local time such as 07:32:00 has no plain YAML form, so it is written with an explicit !!timestamp tag; replace it with a quoted string if your YAML consumer does not understand the tag.
Common errors
- "trying to redefine an already defined table or value" means the same key or table appears twice, which TOML forbids.
- "invalid value" usually points to a missing value after
=or an unquoted string.
Comments are not carried over, since they are not part of the parsed data. To go back, use YAML to TOML. For JSON instead of YAML, try TOML to JSON, and tidy the source first with the TOML formatter if it is hard to read.
Differences to keep in mind
| Topic | TOML | YAML |
|---|---|---|
| Null | No null value exists | null or ~, so converted files never contain it |
| Comments | # | #, but they are not carried over |
| Indentation | Ignored | Defines the structure; spaces only |
| Types | Always explicit | Inferred from the text, hence the quotes on number-like strings |
The last row matters most when you edit the YAML later. Removing quotes from '1.0' or '2021' silently turns them into numbers, and some tools then read the version 1.10 as 1.1. Leave the quotes where the converter put them.
Privacy
The conversion runs in your browser. Your TOML file is not uploaded.