Guide
Converting JSON into readable YAML
By Logappradeep · ServiceNow developer
YAML is the configuration language of modern infrastructure: Kubernetes manifests, Helm values, Docker Compose files, GitHub Actions and GitLab CI pipelines, Ansible playbooks, and many OpenAPI specs are written in it. YAML 1.2 is designed as a superset of JSON, so every JSON document is already valid YAML, but nobody wants to maintain braces and quotes in a config file. Converting to idiomatic YAML gives you indentation-based structure that is easier to read and review.
What the conversion looks like
{"service": {"name": "api", "ports": [80, 443], "debug": false}}
becomes:
service:
name: api
ports:
- 80
- 443
debug: false
Objects become indented key-value mappings, arrays become lists with a leading dash, and plain strings lose their quotes where it is safe.
Why some strings stay quoted
YAML infers types from unquoted text, so the converter quotes any string that would otherwise be read as something else. A JSON string "123" is written as '123' so it does not become a number, and strings such as 'no', 'yes', or 'null' are quoted so older YAML 1.1 parsers do not turn them into booleans or null. Keep those quotes when you edit the file; removing them can silently change the type.
Other details worth knowing
- Multi-line strings are emitted as block scalars using the
|indicator, which keeps line breaks intact and is far easier to read than\nescapes. - Indentation is spaces only. YAML forbids tab characters for indentation, so if you edit the output in an editor set to tabs, the file will break.
- Key order is preserved as it appeared in your JSON, which keeps diffs predictable.
- No comments are generated because JSON has none to carry over. Add explanatory comments with
#after converting; that is one of YAML's main advantages for config files. - Anchors are not created. Repeated blocks stay repeated. You can refactor them into anchors and aliases by hand if your tooling supports them.
Typical workflows
Turning kubectl get -o json output into a manifest you can edit, converting a JSON OpenAPI document into YAML for easier review, rewriting a JSON config for a tool that prefers YAML, and drafting CI pipeline steps from structured data.
The conversion happens locally in your browser, so internal hostnames, secrets references, and other config details are not uploaded.