YAML to JSON Converter
Convert YAML from Docker Compose, Kubernetes, GitHub Actions or any config file into JSON, with clear error messages that give the line number.
Results
What this tool does
This reads YAML by the rules of version 1.2, which is what most modern tools follow: only true and false are booleans, so yes, no, on and off stay text, and the on: key of a GitHub workflow is not turned into true as older readers do. Numbers lose their leading zeros, 0x and 0o become decimal, ~ and null become null, and | and > blocks keep or fold their lines as written. It covers the YAML used in everyday configuration: mappings, lists, inline [lists] and {maps}, all three quoting styles, comments and the --- marker. Anchors and aliases (& and *), tags and multiple documents are reported rather than guessed; if there is an indentation error, the message gives the line.
Formula
indentation → objects and lists ; YAML 1.2 true/false, null and numbers become JSON values ; everything else stays text
Variables
| Symbol | Meaning | Unit |
|---|---|---|
text | YAML | — |
indent | Spaces of indentation | — |
OUT | JSON | — |
FI | Values written | — |
DP | Nesting depth | — |
Worked example
- YAMLservices: web: image: nginx:1.25 ports: - "80:80" environment: DEBUG: false WORKERS: 4 db: image: postgres:16 volumes: [data:/var/lib/postgresql/data]
- Spaces of indentation2
- JSON{ "services": { "web": { "image": "nginx:1.25", "ports": [ "80:80" ], "environment": { "DEBUG": false, "WORKERS": 4 } }, "db": { "image": "postgres:16", "volumes": [ "data:/var/lib/postgresql/data" ] } } }
- Values written10
- Nesting depth4
Limitations
- The calculation runs entirely in your browser. The values you type are never sent to a server.