JSON ↔ YAML Converter
Convert JSON to YAML and back, quoting the strings that would otherwise be read back as numbers or booleans.
Input
Output
Formatting by parsing, not by regex
The document is parsed into a real structure and written back out, so formatting it also proves it parses. A file that cannot be read fails with a line number rather than being silently reindented into something else.
Round-tripping also normalises the parts of YAML that have several spellings: `yes`, `on` and `true` all mean the same boolean, and come back as `true`.
The quoting rule that catches people out
YAML reads unquoted scalars by shape. The Norway problem is the famous case — the country code `NO` parses as the boolean false — and a version string like `1.10` becomes the number 1.1, losing the trailing zero.
When writing YAML here, any string that would be read back as a number, a boolean or null is quoted automatically. That is why `port: "8080"` stays a string while `port: 8080` does not.
Frequently asked questions
Which parts of YAML are not supported?
Anchors and aliases (&a / *a), custom tags, complex mapping keys and merge keys. Block mappings, sequences, flow collections, comments, quoted strings and block scalars all work, which covers ordinary configuration.
Why did my value change type?
Because YAML read it that way. `1.10` is a number, `NO` is false and `null` is not the string "null". Quote the value if you meant text — that is what the converter does when writing.
Are comments preserved?
No. Formatting parses the document into data, and comments are not part of the data. Minify or reformat a file you still need the comments in only from a copy.