Skip to main content
CalcChef

YAML to JSON Converter

Convert YAML to JSON with anchors and merge keys resolved, YAML 1.2 or 1.1 typing for yes/no, and a warning for numbers JSON cannot hold. How it works

Use the YAML to JSON Converter

Your YAML is kept in this browser only (local storage) so it is still here next visit; nothing is uploaded. Limit: 100,000 characters. Anchors and merge keys (<<) are resolved, and YAML 1.2 is read by default: yes, no and on stay text.

JSON Output
{
  "name": "John",
  "age": 30,
  "active": true,
  "tags": [
    "dev",
    "ops"
  ]
}
1 document · 6 lines · 4 keys · max depth 2

About the YAML to JSON Converter

In YAML to JSON conversion, true becomes true but yes stays the text "yes", because this converter reads YAML 1.2 by default and YAML 1.2 treats only true and false as booleans. Tick the YAML 1.1 option for files written for older readers: then yes, no, on and off become booleans and 017 is the octal number 15.

How YAML values come out in JSON

YAML valueJSON with YAML 1.2 (default)JSON with the YAML 1.1 option
yes"yes"true
no"no"false
on"on"true
off"off"false
y"y"true
NO"NO"false
truetruetrue
"yes""yes""yes"
0171715
0o1715"0o17"
0x1F3131
1_000"1_000"1000
12:30"12:30"750
2024-01-15"2024-01-15""2024-01-15T00:00:00.000Z"
~nullnull
1.101.11.1
900719925474099390071992547409929007199254740992
.nannullnull

Each row is the JSON for a: followed by the value. 12:30 in YAML 1.1 is a base-60 number (12 × 60 + 30). The last two rows come with a warning: 9007199254740993 loses its last digit because JSON numbers are 64-bit floats, and .nan has no JSON form.

Frequently asked questions

Why does yes stay a string in the JSON?
YAML 1.2, the default here, reads only true and false (as true, True or TRUE) as booleans, so yes, no, on and off are text. YAML 1.1 also read those words, plus y and n, as booleans. Tick the YAML 1.1 option to read them that way, or write true and false.
Are anchors, aliases and merge keys supported?
Yes. &name and *name are expanded, and a << merge key copies a mapping in, so a base of x: 1 merged into a mapping with y: 2 gives {"x":1,"y":2}. Expansion stops at 50,000 values and 2,000,000 characters of JSON, which keeps a hostile file from freezing the page.
What happens to a file with several documents?
Documents separated by --- become one JSON array in their order, and a note says so: a: 1, then ---, then b: 2 gives [{"a":1},{"b":2}].
Why did my large number change?
JSON numbers are 64-bit floats, which hold whole numbers exactly only up to 9,007,199,254,740,991. 9007199254740993 comes out as 9007199254740992, and the converter warns about it. Quote IDs and other long numbers in the YAML to keep them as text.
Is my YAML saved?
Yes, in this browser’s local storage, so it is still there on your next visit; it is not uploaded. Clear Saved Values removes it and brings back the example.

Related Tools

View all tools