JSON ↔ YAML Converter
Convert JSON to YAML or YAML to JSON instantly.
What is JSON to YAML Conversion?
JSON and YAML represent the same data model — objects, arrays, strings, numbers, booleans, and null — but with very different syntax. JSON uses brackets, braces, and double quotes. YAML uses indentation and clean key-value pairs. Converting between them is lossless: any valid JSON can be converted to YAML and back without losing information.
JSON is the standard for REST APIs and JavaScript environments. YAML is the standard for configuration files — Kubernetes manifests, Docker Compose, GitHub Actions workflows, Helm charts, and Ansible playbooks are all written in YAML. This tool converts instantly in both directions, making it easy to switch between API data and config formats.
Example Conversion
JSON:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": { "name": "my-service" },
"spec": {
"ports": [{ "port": 80, "targetPort": 8080 }]
}
}YAML:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- port: 80
targetPort: 8080JSON vs YAML Syntax
| JSON | YAML |
|---|---|
| { "key": "value" } | key: value |
| ["a", "b", "c"] | - a - b - c |
| "string" | string (quotes optional) |
| true / false | true / false (or yes/no) |
| null | null or ~ |
| // not supported | # this is a comment |
Common Use Cases
- ▸Kubernetes manifests — Convert JSON API responses to YAML configs for kubectl apply
- ▸Docker Compose — Create docker-compose.yml from JSON templates
- ▸CI/CD pipelines — GitHub Actions, GitLab CI and CircleCI all use YAML configs
- ▸Ansible playbooks — Convert JSON data to YAML format for Ansible automation
- ▸Helm charts — Generate values.yaml files from JSON configuration
Special Characters in YAML
The converter automatically quotes strings that could be misinterpreted by YAML parsers:
"123abc""host:port""yes", "no", "true""#", "&", "*"Programmatic Conversion
JavaScript (Node.js):
const yaml = require('js-yaml');
const jsonData = { name: 'example', count: 42 };
const yamlString = yaml.dump(jsonData);
console.log(yamlString);Python:
import json, yaml
with open('data.json') as f:
data = json.load(f)
with open('data.yaml', 'w') as f:
yaml.dump(data, f, default_flow_style=False)