One box for both directions
Paste JSON and you get YAML. Paste YAML and you get JSON. With Detect automatically on, the tool looks at your input and decides. If you would rather decide yourself, choose JSON to YAML or YAML to JSON. The button Use result as input moves the result back into the box, so you can convert back and forth.
The same data in both formats
{
"name": "my-app",
"debug": true,
"ports": [80, 443],
"owner": { "name": "Alex", "email": "alex@example.com" }
}
name: my-app debug: true ports: - 80 - 443 owner: name: Alex email: alex@example.com
Options when writing YAML
- Indent: 2 or 4 spaces. Two is the most common choice.
- Indent list items: on, the items sit under their key. Off, the dashes line up with the key.
- Line width: never wrap long text, or fold it at 80 or 120 characters.
- Style: block style everywhere, or short inline lists and maps such as
[80, 443]from a level you choose. - Quotes: single or double quotes where quotes are needed, or quote every string.
- Sort keys and start with ---.
Strings that YAML could misread are quoted for you: "yes", "no", "null", "007" and "1.10" keep their quotes, so they stay text when the YAML is read again. Multi-line strings become block scalars.
Options when writing JSON
- Indent: 2 spaces, 4 spaces, a tab, or minified.
- Sort keys for a stable, comparable result.
- Schema: the default reads dates as timestamps and supports merge keys. The core and JSON schemas read dates as plain text.
- Duplicate keys: an error by default, because YAML does not allow them. You can let the last one win.
- Several documents separated by
---become a JSON array, or JSON Lines.
What does not survive the conversion
- Comments. JSON has none, so YAML comments are lost when you convert to JSON. To tidy YAML and keep its comments, use the YAML formatter.
- Anchors and merge keys (
&defaults,*defaults,<<:) are expanded, so the values are repeated in the JSON. - Dates written as 2024-05-01 are timestamps in YAML and become text such as "2024-05-01T00:00:00.000Z" in JSON.
- Special numbers such as .inf and .nan do not exist in JSON and become null.
Warnings you will see
The tool points out values that different YAML readers understand differently: unquoted yes, no, on and off (booleans in YAML 1.1, text in 1.2), numbers with a leading zero such as 0755 (read as octal), a version such as 1.10 (read as the number 1.1), and integers too big for JavaScript to hold exactly. Quote such values if you mean text.
A check on the result
When you convert to YAML, the tool reads its own result again and compares it with your original data. If they match, it says so. If they do not, you are told, so a wrong conversion does not go unnoticed.
Private and free
The conversion runs in your browser. Nothing you paste is uploaded. The YAML work is done by the open-source js-yaml library, included in this page.
Single-direction pages: JSON to YAML and YAML to JSON. To check or tidy YAML, see the YAML validator, the YAML formatter and the YAML beautifier. Learn the syntax in the YAML syntax guide, and choose between the formats with the JSON vs YAML guide. You may also need JSON diff, JSON to CSV or JSON to XML.