JSON to YAML Converter
Private: nothing leaves your browser
Paste YAML on the left and the JSON appears on the right.
Paste JSON and get readable YAML: indentation instead of braces, no quotes where none are needed, and multi-line strings written as proper blocks. It runs on your own device, so an API response with real data in it stays with you.
About converting JSON to YAML
JSON is what programs emit, and it is not pleasant to edit by hand: every string quoted, every level in braces, no comments and no forgiveness about a trailing comma. YAML holds the same information with the structure carried by indentation, which is why configuration files ended up written in it. Converting an example response, a package file or a policy document into YAML is usually the first step to turning it into something a person maintains. JSON that will not parse in the first place is worth putting through the JSON validator, which names the line and column that broke.
Quoting is applied only where it is needed. A plain word is left bare, but a value that would otherwise be read back as a number, a boolean or null keeps its quotes, and so does anything with leading space, a leading dash or a colon followed by a space. That is the difference between YAML that round trips and YAML that quietly changes meaning, and you can check it here with Result to input.
Strings with line breaks in them are written as a |- block rather than one long line full of escaped newlines, which is the main reason converted YAML is easier to read than the JSON it came from.
How to convert JSON to YAML
- Paste your JSON into the left box. The YAML appears on the right as you type.
- If the JSON will not parse, the status line repeats your browser's own message, including the position.
- Switch to YAML to JSON to go back the other way.
- Press Result to input and then convert again to prove the file survives a round trip unchanged.
- Press Copy to take the result.
Common questions about JSON to YAML
Where does the conversion actually run?
Why are some values quoted and others not?
How are nested arrays and objects written?
{} and an empty array as [], since there is no block form for either.
What happens to a string containing newlines?
|- block scalar, with the text laid out on its own indented lines. The alternative would be one very long quoted line full of backslash-n, which is legal but unreadable. The - means no newline is added at the end, so the value comes back exactly as it went in.
Can I add comments to the result?
# is a comment, and that is one of the main reasons to convert a config out of JSON in the first place. Bear in mind that converting back to JSON will drop them again, since JSON has nowhere to put them.Next