About json ↔ yaml
YAML is a human-friendly format used for configuration files such as Docker Compose, Kubernetes and GitHub Actions. It is a superset of JSON, so conversion is straightforward.
Be careful with YAML
- Indentation is meaningful. Use spaces, never tabs.
- Values like yes, no, on and off may be read as booleans.
- Strings with colons or leading special characters should be quoted.
Both directions
Convert JSON to YAML to make configuration readable, or YAML to JSON to feed tools that expect JSON.
A worked example
{"name":"Asha","skills":["sql","python"]} becomes name: Asha followed by skills with two dash-prefixed lines. Converting back returns the same data. YAML adds comments, which JSON cannot hold, so they are lost when going back.
Common YAML traps
The string NO may be read as false, 1.10 as the number 1.1, and a value starting with * or & as special syntax. Quote any value where the type matters.
