JSON to YAML: Write Config Files Every YAML Parser Reads the Same Way
By FindMySum · Last reviewed
This JSON to YAML converter rewrites JSON as clean, readable YAML for configuration files: Kubernetes manifests, Docker Compose files, GitHub Actions and Ansible playbooks. Paste JSON above and the YAML appears as you type. It is converted in your browser, so API keys and passwords that end up in config stay on your device.
Why convert JSON to YAML
The two formats hold the same data, and every JSON document is already valid YAML. YAML is easier to read and edit by hand: no braces or quotes around every key, and comments are allowed. That is why tools that people configure by hand prefer it, while APIs and programs exchange JSON. A typical case is copying an API response, or the output of kubectl get -o json, into a file a person will maintain.
How to use it
- Paste the JSON. If it has a mistake, the error message shows where.
- Pick the indentation your project uses; 2 spaces is the most common.
- Choose whether lists sit under their key (the Kubernetes style) or level with it.
- Leave the YAML 1.1 quoting on unless you know every program that reads the file follows YAML 1.2.
- Copy or download the YAML.
A worked example
{"app": "shop", "replicas": 2, "debug": "off", "ports": [80, 443], "motd": "Hello\nWorld"}
becomes:
app: shop
replicas: 2
debug: "off"
ports:
- 80
- 443
motd: |-
Hello
World
The number 2 stays a number and the ports a list. The string "off" is quoted because a YAML 1.1 parser would read a bare off as false. The two-line message becomes a literal block, where |- means "keep the line breaks, no final newline".
Common mistakes
Assuming YAML is whitespace-forgiving. Indentation decides structure. When you edit the output, keep each level aligned and use spaces, never tabs.
Removing "unnecessary" quotes. A quote around "0755", "no" or "1.10" is there for a reason: without it the value changes type, and a version number 1.10 becomes the float 1.1.
Pasting JavaScript instead of JSON. Single quotes, unquoted keys and trailing commas are errors, and the message shows where. The JSON formatter with its JSONC option removes comments and trailing commas for you.
To check how a parser reads YAML you already have, use the YAML to JSON converter.