JSON to YAML Converter
Convert JSON into YAML. Strings are quoted only where quoting is necessary to stop them being read back as a number, boolean or null.
Your data never leaves your browser. This tool runs entirely on your device.
How YAML and JSON relate
Every JSON document is also valid YAML — YAML 1.2 is a strict superset. The reverse is not true, because YAML has features JSON does not: comments, anchors and references, multiple documents in one file, and several ways of writing multi-line strings.
That is why converting JSON to YAML always works, while converting YAML to JSON can fail or lose information.
What gets lost converting YAML to JSON
Comments disappear, because JSON has no way to represent them. Anchors and aliases are expanded into repeated copies of the data. Multiple documents separated by --- cannot be represented at all.
If your YAML is a configuration file where the comments carry the explanation, keep the original — the JSON is a data view of it, not a replacement.
The Norway problem
YAML 1.1 parsers read unquoted no, yes, on and off as booleans, which famously turned the country code NO into false. YAML 1.2 removed this, but plenty of tools still use the old behaviour.
The lesson is to quote strings that could be mistaken for another type: "no", "yes", "null", "1.0" and version numbers like "1.10" are all worth quoting explicitly.
Frequently asked questions
Is JSON valid YAML?
Yes. YAML 1.2 is a strict superset of JSON, so any valid JSON document can be parsed by a YAML parser. The opposite is not true.
What happens to my comments?
They are lost. JSON has no comment syntax, so converting YAML to JSON discards them. Keep the YAML original if the comments matter.
Why did my value "no" become false?
Older YAML parsers following the 1.1 spec treat unquoted no, yes, on and off as booleans. Quote the value as "no" to keep it a string. This is the well-known Norway problem.
Why does indentation matter so much in YAML?
Indentation defines structure, the way braces do in JSON. Inconsistent indentation changes the meaning or causes a parse error. Tabs are forbidden entirely — YAML requires spaces.
Related tools
- YAML to JSONConvert YAML into JSON. Parse errors are reported with a line and column so you can find the problem, which in YAML is usually indentation.
- JSON FormatterPaste JSON to pretty-print it with consistent indentation, or minify it back down. Invalid JSON is reported with the exact line and column so you can find the problem.
- JSON MinifierStrip every unnecessary character from JSON to make it as small as possible for transmission or storage. The result is byte-for-byte equivalent data.
- XML FormatterRe-indent XML so its structure is readable, and find out immediately if it is not well-formed. CDATA sections and declarations are preserved exactly.