YAML looks like plain text, which is why it is used for configuration, and why it surprises people. The same text can be read as different data by different tools. A country code of NO is the text NO in one reader and the boolean false in another. A file mode of 0755 is the number 755 in one and 493 in another. A clock time of 12:30:45 can be a number of seconds. A key that is written twice can be an error or can silently keep the last one. Most converters show you one reading and say nothing about the others.
This page converts in both directions, and it also reads your YAML the other way and tells you where the two readings differ. You choose whether the output follows YAML 1.2, the current version, or YAML 1.1, which PyYAML and many older readers follow, and a table lists every value that would change. Errors come with a line and a column. Everything is done in your browser, and the code behind the page makes no network requests, so a configuration file with secrets in it does not leave your device.
How to use the YAML to JSON: Convert and See Where YAML 1.1 and 1.2 Differ
- Paste the YAML, or open a filePaste the text, or open a .yaml, .yml, or .json file of up to 5 MB, which is read on your device. A file with several documents, separated by lines of three dashes, becomes an array in JSON.
- Choose how to read itYAML 1.2 is the current version. Choose YAML 1.1 if the file is read by PyYAML or another older reader, so that the JSON shows what that reader will see. Choose the JSON indent, and whether to sort the keys.
- Read the differencesUnder the JSON, a table lists every place where YAML 1.1 and 1.2 give different values for your text. If a value there is one that you meant as text, put it in quotes in the YAML, and then every reader agrees.
- Fix an error, or go the other wayAn error has a line and a column, and the line button takes you there. To write YAML from JSON, choose JSON to YAML. The result is written so that a 1.1 reader and a 1.2 reader get the same data back.
Why YAML 1.1 and 1.2 give different answers
YAML 1.2, published in 2009, is the current version of the language. Its core schema is small: the booleans are true and false, in three spellings of the case, and the null is null, ~, or nothing. YAML 1.1, from 2005, has a larger set of plain values. The words yes, no, on, and off, and in the specification y and n, are booleans. A number that starts with 0 is an octal number, so 0755 is 493. A number with a colon, such as 190:20:30, is in base 60, a leftover of the way that minutes and seconds are written. Underscores are allowed inside numbers, a date is a timestamp, and 0b101 is binary.
Most parsers sit between the two. PyYAML follows the 1.1 text, with some choices of its own, and ruamel.yaml reads 1.2 by default. A parser can also be written to the 1.2 text and still read a few of the old forms. So a file that works on one machine can be read differently on another, and the difference comes from a value that nobody quoted.
The Norway problem
The best known case is a list of country codes: GB, DE, NO. In YAML 1.1, NO is a boolean, so the list becomes GB, DE, false. The same happens with a key named on or yes, and with a value such as n in a list of answers. A version number of 1.10 is read as the number 1.1, and a file mode written as 0755 without quotes is read as 493 in 1.1 and as 755 in 1.2, which is wrong in both ways for a mode.
The page does not choose for you. It shows both readings in two columns, with the path of each value, so that you see what a 1.1 reader gets and what a 1.2 reader gets. The remedy is the same for all of them: write the value in quotes, such as "NO", and every reader gets the text.
Keys written twice, and merge keys
The YAML specification says that the keys of a mapping must be unique. PyYAML does not enforce it, and takes the last value, so a duplicate can go unnoticed for years. This page refuses a document with a key that is written twice, and says on which line, because the usual cause is a mistake and the JSON would hide it. In YAML 1.1 the keys yes and on are both the boolean true, so they count as the same key, and the page refuses them too.
The merge key, written as <<, copies the entries of an anchored mapping into another one. It is in the YAML 1.1 types and not in the 1.2 core schema, but Docker Compose files, CI configurations, and most tools use it, so the page applies it in both versions. Anchors and aliases are read, and a document that expands through aliases to a huge size is refused, because that is how a small file can use all the memory of a machine.
What JSON cannot hold
JSON has objects, arrays, strings, numbers, true, false, and null, and YAML has more. A timestamp, which YAML 1.1 reads from a date, is written as a string in ISO 8601 form. Binary data, from the !!binary tag, is written as base64 text. The values .nan, .inf, and -.inf have no JSON form, and are written as null. A key that is not text, such as a number, true, null, or a list, becomes text. An integer of more than 15 digits is written in full, and the page says so, because a program that reads JSON numbers as floating point rounds it. Each of these produces a note under the output.
The keys of an object stay in the order of the YAML, even when they are numbers. That is not so obvious as it sounds, because a JavaScript object puts keys such as 1 and 2 first whatever the order, and so the page keeps the order in its own structure.
JSON to YAML that every reader reads the same
JSON is valid YAML in nearly every case, but readable YAML has no braces and no quotes, and that is where the trouble is. A string that is yes, no, 0755, 1e3, a date, or a clock time is written without quotes by most tools, and a reader of the other version gives a different value back. The page quotes every text that either version would read as something else: the booleans and nulls of both versions, numbers in the forms of both, dates, base 60 numbers, 0o17, which is octal in 1.2, the words << and =, text with a tab or another control character, and a text that has line breaks and starts with a space or a line break.
A number with an exponent and no point, such as 1e+21, is written as 1.0e+21, because YAML 1.1 reads the first as text. A document that is one text with line breaks is written in quotes, because PyYAML cannot read a block of text at the top level. Integers keep every digit, and the keys keep their order. The page does not add comments or anchors, since JSON has none.
How it was tested
The reading was compared with two other readers. 700 documents were made from the values that readers disagree about: yes, no, on, off, null, ~, numbers with leading zeros, in octal, hexadecimal, and binary, with exponents and with a point, .inf and .nan, dates, times, text with colons, hashes, brackets, quotes, accents, Chinese text, and emoji, in mappings, lists, flow collections, block text, anchors, merge keys, and several documents. Each was read by ruamel.yaml for YAML 1.2 and by PyYAML for YAML 1.1. The page gave the same data in all of the 1,055 readings that the references could read, and refused 322 that both references refused. 23 documents had two keys that are the same value in the version used, which PyYAML accepts and this page refuses.
A few things were left out of those documents on purpose, because the references differ from the specification or from each other, and each is listed and tested on its own: y and n, which the 1.1 text makes booleans and PyYAML leaves as text, numbers with underscores, which ruamel.yaml reads in 1.2 and the 1.2 core schema does not, a plus sign before .5, an exponent without a sign, a lone dash in a flow list, and a few explicit tags. The page follows the specification in these cases. Dates are read as timestamps only in 1.1, and 1.2 keeps them as text, while ruamel.yaml reads them as timestamps even in 1.2.
The YAML that the page writes from JSON was tested in the other direction. 500 documents of random JSON, with 87 kinds of text that readers misread and 16 kinds of number, were written as YAML and read back by PyYAML and by ruamel.yaml. Both gave the original data back for all 500. In an earlier version, a text of a tab, the word <<, a number such as 1e+21, a text that starts with a line break, and 0o17 each failed one of the two readers, which is how those rules were found.
Limits and accuracy
- The parser is the yaml package for JavaScript, by Eemeli Aro, version 2. The page was compared with ruamel.yaml and PyYAML, and it does not claim to match every other reader, such as the ones in Go, Ruby, or Java. The 1.1 reading follows the specification, and some readers differ from it, as the notes above say.
- Comments are not kept, because JSON has none, and the YAML that the page writes has no comments or anchors. Keys that repeat a value through an alias are written out in full.
- Explicit tags, such as !!float on a value that is not written as one, are read the way the library reads them, and a few of them differ from PyYAML and ruamel.yaml. Custom tags of your own are kept as text.
- A file or a text of more than 5 MB is not read, and a document with more than 100 aliases expanded is refused.
- JSON has no way to write a few of the values of YAML, which are listed in the notes under the output, and the conversion of those is one way: JSON to YAML gives back the text or the null, and not the timestamp or the binary data.
- Nothing you paste is saved, so copy the result or download it before you close the page.
Frequently asked questions
How do I convert YAML to JSON?
Paste the YAML on this page, choose how to read it, and copy the JSON. If the text has errors, the page names them with their line and column. A file with several documents becomes an array.
What is the difference between YAML 1.1 and 1.2?
In YAML 1.1, yes, no, on, and off are booleans, a number that starts with 0 is octal, and timestamps and base 60 numbers exist. In 1.2 the booleans are only true and false, and those forms are text. The page shows where your text differs between them.
Why did NO become false?
Because a YAML 1.1 reader takes NO for a boolean. A YAML 1.2 reader keeps it as the text NO. Put it in quotes, "NO", and every reader gets the text. The page lists such values for your file.
Why does it refuse my file because of a duplicate key?
Because the YAML specification says that keys must be unique, and a repeated key is nearly always a mistake. Some readers keep the last value without a warning. In YAML 1.1, yes and on are the same key, true, and count as a duplicate.
Does it keep comments?
No. JSON has no comments, so they are dropped when YAML is converted to JSON, and the YAML that the page writes from JSON has none.
Can it convert JSON to YAML safely?
Yes. It quotes every text that a reader of either version would take for something else, such as yes, no, 0755, or a date, so that PyYAML and ruamel.yaml both read back the same data. Integers keep every digit.
What happens to dates in YAML?
In YAML 1.1 a date is a timestamp, and the page writes it in JSON as a string in ISO 8601 form, with a note. In YAML 1.2 a date is text, so it stays text. Put a date in quotes if you want it to be text in both.
Is my file uploaded?
No. The text and the file are read in your browser, and the code behind the page makes no network requests. Nothing is saved.
Research and references
This page was written and checked against the sources below.

