YAML to JSON Converter
Paste YAML to get JSON, or flip the direction to turn JSON into YAML. Errors show the line and column, and anchors and multi-document files are handled.
Last updated
YAML
JSON
Converted{
"services": {
"api": {
"image": "devnest/api:1.4.2",
"ports": [
"8080:8080"
],
"environment": {
"LOG_LEVEL": "info",
"FEATURE_FLAGS": [
"search",
"exports"
]
},
"healthcheck": {
"test": [
"CMD",
"curl",
"-f",
"http://localhost:8080/health"
],
"interval": "30s",
"retries": 3
}
}
}
}Keyboard shortcuts:Ctrl ↵Copy outputCtrl SDownloadCtrl KSearch tools
How to use the YAML to JSON Converter
Choose a direction
YAML → JSON is selected by default. Switch to JSON → YAML to go the other way.
Paste your data
Paste a config file, Kubernetes manifest, OpenAPI spec or any other YAML or JSON.
Fix any errors
If the input is invalid, the output panel shows the problem with its line and column.
Copy or download
Copy the result or download it as a .json or .yaml file. Switching direction moves the result into the input.
Features
- Converts YAML to JSON and JSON to YAML, updating as you type
- Error messages with the exact line and column
- Anchors, aliases and << merge keys are expanded in the JSON output
- Multi-document YAML (separated by ---) becomes a JSON array
- 2- or 4-space indentation
- Switching direction moves the current result into the input, so you can round-trip
- Copy, or download as .json or .yaml — also with Ctrl/Cmd + Enter and Ctrl/Cmd + S
Privacy
Your YAML and JSON are processed by JavaScript in your browser tab. Nothing is uploaded or stored, and the page's security policy blocks it from sending data to any other site.
Examples
Kubernetes manifest to JSON
Indentation becomes nested objects and dashes become arrays.
YAML
apiVersion: apps/v1 kind: Deployment metadata: name: api spec: replicas: 3 template: spec: containers: - name: api image: devnest/api:1.4.2 ports: - containerPort: 8080JSON
{ "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": "api" }, "spec": { "replicas": 3, "template": { "spec": { "containers": [ { "name": "api", "image": "devnest/api:1.4.2", "ports": [ { "containerPort": 8080 } ] } ] } } } }Anchors and merge keys
<< copies the anchored defaults, and the local timeout overrides them.
YAML
defaults: &defaults retries: 3 timeout: 30 production: <<: *defaults timeout: 60JSON
{ "defaults": { "retries": 3, "timeout": 30 }, "production": { "retries": 3, "timeout": 60 } }JSON to YAML
Turn a minified JSON config into readable YAML. Loads with JSON → YAML selected.
JSON
{"name":"sensor-gateway","version":"2.1.0","scripts":{"start":"node index.js"},"keywords":["mqtt","iot"]}YAML
name: sensor-gateway version: 2.1.0 scripts: start: node index.js keywords: - mqtt - iot
Understanding YAML and JSON
YAML vs JSON
YAML and JSON describe the same kinds of data — objects, arrays, strings, numbers, booleans and null. JSON is strict and easy for programs to parse; YAML is designed for people, with indentation instead of braces, comments and less punctuation. That's why config files (Docker Compose, Kubernetes, GitHub Actions) use YAML while APIs use JSON.
| Aspect | YAML | JSON |
|---|---|---|
| Structure | Indentation | Braces and brackets |
| Comments | Yes (#) | No |
| Quotes on strings | Usually optional | Always double quotes |
| Anchors and references | Yes (& and *) | No |
| Multiple documents per file | Yes (---) | No |
Anchors, aliases and merge keys
YAML can define a value once with &name and reuse it with *name. The << merge key copies the keys of an anchored map into another map. JSON has no equivalent, so the converter writes out the full values:
defaults: &defaults
retries: 3
timeout: 30
production:
<<: *defaults
timeout: 60
→ "production": { "retries": 3, "timeout": 60 }Common YAML mistakes
- Tabs for indentation — YAML only allows spaces.
- Inconsistent indentation inside one list or map.
- A missing space after the colon:
key:valueis a single string, not a key and a value. - Unquoted values that start with special characters such as
*,&,@or{. - Values like
yes,no,onandoffare booleans in YAML 1.1 tools but strings in YAML 1.2 (this converter follows 1.2). Quote them to be safe.
Frequently asked questions
Can I convert JSON to YAML too?
Yes. Switch the direction to JSON → YAML. Switching moves the current result into the input, so you can convert back and forth.
What happens to comments when converting YAML to JSON?
They are dropped, because JSON has no comment syntax. Converting JSON back to YAML won't bring them back.
How are multiple YAML documents converted?
A file with several documents separated by --- becomes a JSON array, with one item per document.
Does it support anchors and merge keys?
Yes. Aliases (*name) are replaced with the anchored value and << merge keys are expanded, because JSON can't express references.
Which YAML version is used?
YAML 1.2, via the open-source yaml library. In 1.2, words like yes, no, on and off are strings rather than booleans.