Convert JSON to YAML
JSON and YAML represent the same data structures but use very different syntax. YAML's indentation-based format is more readable for humans, making it the preferred choice for configuration files in Kubernetes, Docker Compose, GitHub Actions, and Ansible. This example converts a typical application configuration JSON to YAML, showing how nested objects become indented blocks and arrays become dash-prefixed lists. The converter handles all JSON types including strings, numbers, booleans, null, arrays, and nested objects.
{
"app": {
"name": "my-service",
"version": "2.0.0",
"port": 8080,
"debug": false
},
"database": {
"host": "localhost",
"port": 5432,
"name": "appdb",
"ssl": true
},
"features": ["auth", "logging", "metrics"],
"limits": {
"maxConnections": 100,
"timeoutMs": 5000
}
}FAQ
- When should I use YAML instead of JSON?
- Use YAML for configuration files that humans edit frequently, such as CI/CD pipelines, Kubernetes manifests, and Docker Compose files. Use JSON for API payloads and data interchange where machine readability is more important.
- Does YAML support comments?
- Yes. YAML supports single-line comments starting with #. JSON does not support comments at all, which is one reason developers prefer YAML for configuration files.
- Are all JSON files valid YAML?
- Technically yes, since YAML is a superset of JSON. However, YAML parsers vary in their JSON compatibility. The converter produces clean YAML syntax rather than JSON-in-YAML.
Related Examples
CSV is the most common export format for spreadsheets and databases, while JSON ...
Convert XML to JSONMany legacy APIs and data exports use XML while modern applications expect JSON....
Format a REST API ResponseREST APIs return compact JSON that is hard to read at a glance. Paste this examp...