Paste your JSON below to convert it to YAML:
Why Convert JSON to YAML?
YAML is the preferred format for configuration files in DevOps tools like Kubernetes, Docker Compose, Ansible, and GitHub Actions. While JSON works programmatically, YAML is more readable for human-edited config files.
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 ~ |
Common Use Cases
- Kubernetes manifests — Convert JSON API responses to YAML configs
- Docker Compose — Create docker-compose.yml from JSON templates
- CI/CD pipelines — GitHub Actions, GitLab CI, CircleCI configs
- Ansible playbooks — Convert JSON data to YAML format
- Helm charts — Generate values.yaml files
Special Characters in YAML
The converter automatically quotes strings that could be misinterpreted:
- Strings starting with numbers:
"123abc" - Strings containing colons:
"host:port" - Boolean-like strings:
"yes","no","true" - Strings with special characters:
#,&,*
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
import yaml
json_data = {"name": "example", "count": 42}
yaml_string = yaml.dump(json_data, default_flow_style=False)
print(yaml_string)Command Line (with yq)
# Using yq
cat data.json | yq -P > data.yaml
# Or directly
yq -P data.jsonPro Tips
- 💡 Validate your JSON first — Use the JSON Validator to catch syntax errors before converting
- 💡 Check indentation — YAML is indentation-sensitive. Our output uses 2-space indentation (Kubernetes standard)
- 💡 Comments don't transfer — JSON doesn't support comments, so add them manually after converting
Related Tools
- YAML to JSON — Convert YAML back to JSON
- JSON Validator — Validate your JSON first
- JSON Diff — Compare JSON documents
Common Mistakes & Pro Tips
- Indentation is significant in YAML — Unlike JSON, YAML uses indentation (spaces, never tabs) to express structure. Our output uses 2-space indentation, the convention for Kubernetes and most CI configs. Mixing tabs and spaces is the most common reason a converted file fails to parse.
- Some strings must be quoted — Values like yes, no, on, off, null, and numbers with leading zeros are interpreted as booleans, null, or octal in YAML 1.1. The converter quotes these automatically so "yes" stays a string instead of becoming true.
- Comments do not survive a round trip — JSON has no comments, so converting JSON → YAML cannot add them, and converting YAML → JSON strips any you wrote. Add YAML comments (#) manually after converting, and keep a source of truth that supports them.
- Key order is preserved, but YAML does not require it — We keep your keys in their original order for readable diffs, but YAML (like JSON) defines mappings as unordered. Do not rely on key order for program logic.
Frequently Asked Questions
Is converting JSON to YAML lossless?
For data, yes — every JSON value (objects, arrays, strings, numbers, booleans, null) maps cleanly to YAML. The only things that cannot transfer are comments (JSON has none) and formatting choices. Converting YAML back to JSON is also lossless for data but drops YAML comments and anchors.
Why does my YAML have quotes around some values?
YAML treats bare words like yes, no, true, null, and numbers specially. To keep a value as a string, it must be quoted. The converter adds quotes only where they are needed to preserve the original JSON type.
How do I convert a JSON API response to a Kubernetes manifest?
Paste the JSON and convert it to YAML, then save it as a .yaml file. Kubernetes accepts both JSON and YAML, but YAML manifests are the convention. Validate the result with kubectl apply --dry-run=client -f file.yaml before applying.
Does the tool support multi-document YAML?
A single JSON value produces a single YAML document. To create a multi-document file (separated by ---), convert each JSON object individually and join the outputs with a --- line between them.
Is my data uploaded anywhere?
No. The conversion runs entirely in your browser using JavaScript — your JSON never leaves your device, which makes it safe for configs containing internal hostnames or secrets.