YAML is the reference configuration format for modern DevOps tools: Kubernetes, Docker Compose, GitHub Actions, Ansible and many others. Converting JSON to YAML allows you to go from a verbose format to a readable and clean format.

YAML is a superset of JSON (all valid JSON is valid YAML), but YAML uses indentation instead of braces and brackets, and removes quotes around simple strings. The conversion is deterministic: JSON objects become YAML indented blocks, JSON arrays become dash-prefixed lists, primitive values are preserved.

📊 Reference table

JSON Equivalent YAML
{"name": "Alice"} name: Alice
{"port": 8080} port: 8080
{"debug": true} debug: true
["a", "b", "c"] - a - b - c
{"db": {"host": "localhost"}} db: host: localhost

💡 Practical examples

Example 1: transform a Docker Compose config You have a JSON describing your Docker services. Convert it to YAML to get a valid docker-compose.yml file ready to use.
Example 2: generate a Kubernetes manifest Kubernetes manifests (Deployment, Service, ConfigMap) are in YAML. Build your structure in JSON, convert and copy into your .yaml file.
Example 3: simplify reading an API response A JSON API response with many levels of nesting is often more readable once converted to YAML for human review.

The other way round: convert YAML to JSON online

YAML is ubiquitous in the DevOps ecosystem but difficult to parse manually and poorly supported in data processing tools. Converting YAML to JSON allows you to use all standard JSON analysis tools: jq, JSON Schema, online validators.

YAML to JSON conversion is the reverse of JSON to YAML. YAML indented blocks become JSON objects, dash-prefixed lists become JSON arrays, YAML scalars are typed according to their value (string, integer, float, boolean, null). YAML anchors and aliases (& and *) are resolved before conversion.

📊 Reference table

YAML (input) JSON (output)
name: Alice {"name": "Alice"}
port: 8080 {"port": 8080}
debug: true {"debug": true}
items: - a - b {"items": ["a", "b"]}
db: host: localhost {"db": {"host": "localhost"}}

💡 Practical examples

Example 1: debug a Helm values.yaml file Convert your values.yaml to JSON to validate it with a JSON Schema or compare it with a configuration expected by a third-party tool.
Example 2: read a GitHub Actions CI/CD workflow GitHub Actions workflows in YAML can be complex. Convert to JSON and use jq to extract step names or environment variables.
Example 3: validate an Ansible config Ansible uses YAML for playbooks. Convert to JSON, validate the structure with a JSON schema tool and ensure all mandatory keys are present.