JSON ⇄ YAML ⇄ TOML
Convert between JSON, YAML and TOML in any direction, with 2 or 4 space indents.
About this tool What it's for, how to use it and an example
What it's for
Convert between JSON, YAML and TOML, in any direction. YAML is common in configuration (Docker Compose, Kubernetes, GitHub Actions, Jekyll); TOML is used by Cargo, pyproject.toml and Hugo; JSON is what most APIs and programs produce.
For example, when documentation gives a config as JSON but your tool wants YAML or TOML, or you want to check how a YAML or TOML file is actually being read, convert it here.
How to use it
Paste your text, choose its format under From and the one you want under To, then choose Convert. Choose a 2 or 4 space indent (used for JSON and YAML; TOML output isn’t indented). The formats you chose are remembered in the browser. Use as input moves the result into the input box and sets From to match, ready for another conversion. Long lines aren’t wrapped. If the input has a mistake, the error message says where.
Example
Paste this, choose From JSON and To TOML, and choose Convert:
{"name":"Alice","roles":["admin","dev"],"address":{"city":"London"}}
The result is:
name = "Alice"
roles = ["admin", "dev"]
[address]
city = "London"
Good to know
TOML has no null, so JSON or YAML containing null can’t be converted to TOML; the message names the key. TOML’s top level must be a table of keys and values, so a JSON or YAML array or single value at the top can’t be TOML. TOML dates and times become ISO text (1979-05-27) in JSON and YAML. Comments in YAML or TOML are lost, because the other formats have none, and YAML’s anchors and aliases are expanded into copies of the values they point to. Arrays of objects become [[table]] sections in TOML.
Built with The third-party code and data this tool uses, and their licences
This tool runs on the following open-source work, copied onto this site and served from it:
- js-yaml 5.4.2
- Copyright
- Copyright (C) 2011-2015 by Vitaly Puzrin
- Licence
- MIT License
- Source
- github.com/nodeca/js-yaml
- smol-toml 1.9.0
- Copyright
- Copyright (c) Squirrel Chat et al.
- Licence
- BSD 3-Clause License
- Source
- github.com/squirrelchat/smol-toml
Every page also uses Montserrat (SIL Open Font License 1.1).
Everything the site uses is on Credits and licences.
Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.
Saved you a few minutes? Say thanks with a coffee.
Something wrong with this tool, or missing from it? Report a bug or suggest a feature.