🔀 JSON to YAML Converter
Convert JSON to YAML or YAML to JSON. Handles nested objects, arrays, strings, numbers, booleans and null. Runs entirely in your browser.
What comes out of each direction
JSON to YAML emits block style with two-space indentation, list items indented under their key, and no document marker. The sample becomes:
name: SimpleMoney Tools
free: true
categories:
- Text
- Dev
- Finance
version: 2
owner: null
A string is only quoted when it needs to be: when it is empty, has leading or trailing
spaces, reads as a number or as true, false or null, or contains one of the characters
that mean something in YAML - : # [ ] { } " ' , & * ! | > % @ and the
backtick. Everything else is written bare.
The subset the YAML side reads
- Block style only. Nested maps, dash lists, quoted and bare scalars,
and whole-line
#comments. Flow style such as{a: 1}or[1, 2], anchors and aliases, and---multi-document files are not handled. - Trailing comments become part of the value.
version: 2 # bumpedparses as the string "2 # bumped" rather than the number 2. - No block scalars. There is no
|or>support in either direction, so a JSON string containing newlines produces YAML that will not parse back.
Frequently asked questions
Why does my YAML value yes turn into true?
YAML 1.1 parsers, including Ruby's and older PyYAML, read yes, no, on and off as booleans - the same rule that turns the country code NO into false. This converter leaves those words unquoted, so quote them yourself if the value must stay a string.
Is every JSON file also valid YAML?
Under YAML 1.2, yes - JSON is a subset, so a real YAML parser accepts it. The parser on this page is not a full one, though: it reads the block style it produces, so paste JSON into the JSON to YAML direction rather than the other one.
Can I keep the comments when converting YAML to JSON?
No, and no tool can - JSON has no comment syntax, so full-line comments are dropped on the way in and nothing recreates them on the way back. Keep the YAML file as the source of truth if the comments matter.