YAML to TOML
Convert YAML to TOML (js-yaml + smol-toml) with clear hints for null values, top-level arrays and mixed-type arrays, errors for broken YAML, optional key sorting and output statistics.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Validation and hints
TOML output
features = [ "markdown", "robots" ] [build] minify = true target = "es2022" [server] host = "127.0.0.1" port = 8080 timeout = 30
Statistics
61210131What this tool does
- Convert YAML config into TOML for a Rust or Python project without rewriting the syntax line by line.
- Draft a pyproject.toml or Cargo.toml structure in YAML first, then convert once the shape looks right.
- Validation runs before conversion: nulls, top-level arrays, integers beyond 64 bits and mixed-type arrays are reported up front instead of producing a broken file.
- Tick sort keys when you want stable output, so the generated TOML diffs cleanly every time.
Example
Input
server: host: 127.0.0.1 port: 8080 timeout: 30 features: - markdown - robots build: target: es2022 minify: true
Output
features = [ "markdown", "robots" ] [server] host = "127.0.0.1" port = 8080 timeout = 30 [build] target = "es2022" minify = true
Array keys are lifted to the top of the file (TOML requires simple keys before tables) and nested objects become the [server] and [build] tables. The stats panel reports 6 keys and 2 tables.
Frequently asked questions
Why is one key at the very top of the file?
TOML requires simple key/value pairs to appear before any table, otherwise the later keys would be captured by the previous table. The serialiser hoists arrays like features to the top to satisfy that rule, which keeps the output parseable.
What happens to null values from the YAML?
TOML has no null, so any key holding one is reported as a blocking issue with its path (for example server.port) and no TOML is produced. Delete the key, or change it to an empty string or false, then convert again.
Can I convert a YAML document whose top level is an array or scalar?
No. A TOML document must be a table at the top level, so an array or bare scalar triggers not-a-map and needs to be wrapped in a key such as value: .... An empty document or one containing only comments is reported separately.
Why is a mixed-type array only a warning?
TOML 1.0 allows arrays with mixed value types, but parsers that only know TOML 0.5 reject them. By default it stays a warning and the output is still generated; turning on strict array types turns it into a blocking error so you can match an older toolchain.
What about big integers and dates?
Integers beyond the JavaScript safe range (2^53-1) are flagged as already losing precision and should be quoted in the YAML source, while anything outside the signed 64-bit range is a blocking error. YAML timestamps become TOML date-times or strings, and the generated TOML is read back with smol-toml as a self-check.
Keywords:yaml to tomlyamltomlconverterserializationYAML 转 TOML配置转换键排序TOML 生成