Convert a YAML config to JSON (and back)
A CI pipeline wants YAML, your script wants JSON. Convert config files between the two without installing a toolchain.
Tools used in this guide
The job
Docker Compose files, GitHub Actions, Kubernetes manifests — the config world speaks YAML, but feeding the same data to a script or API usually wants strict JSON.
Convert it
Paste the YAML and convert — the parser builds nested maps and lists from indentation, then the JSON view shows the same structure. The reverse direction emits readable block-style YAML.
- Quoted strings, flow collections, comments, and block scalars (| and >) are handled.
- Anchors, aliases, tags, and multi-document files are rejected with a clear error instead of silently mis-parsed.
Worked example
A docker-compose.yml with services, ports as a list, and environment variables converts to a JSON object with the same keys — "ports" stays an array of strings, quoted "80:80" stays a string, not a number.
Scope to expect
The parser is a documented subset covering typical hand-written configs, not every YAML 1.2 feature. If your file uses anchors or custom tags, the error tells you rather than producing wrong output.
- Input up to 500 KB; one leading --- document marker is allowed.
- Everything converts locally — configs can contain hostnames and credentials that should not leave the machine.