YAML to JSON Converter
Convert YAML to JSON and JSON to YAML, with multi-document files, anchors and the YAML 1.2 rules Docker Compose and Kubernetes use.
Free · No sign-up · Your inputs stay in your browser
Input
Convert YAML to JSON and back
Output
Result
314 characters
Parsed with js-yaml under the YAML 1.2 core schema, where yes, no, on and off are strings, not booleans. Docker Compose and Kubernetes follow 1.2; old YAML 1.1 parsers (PyYAML) still turn NO, the country code for Norway, into false.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
YAML is a superset of JSON
Since YAML 1.2, every JSON document is valid YAML, so JSON can be pasted into a Compose file or a Kubernetes manifest as it is. The reverse is not true: YAML has comments, anchors and aliases, multi-line strings and several documents per file, none of which JSON can represent. Comments are lost in conversion.
The Norway problem
YAML 1.1 read yes, no, on and off as booleans, so a list of country codes containing NO came back with false in it. YAML 1.2's core schema reads them as strings. PyYAML still follows 1.1, which is why a file can mean different things to two tools. Quote any value that must stay a string.
Indentation
YAML forbids tabs for indentation. A tab, or a non-breaking space pasted from a web page, is the most common cause of a parse error on a line that looks fine.