How to use the JSON to YAML
- Paste JSON into the JSON pane, open a
.jsonfile, or click Load sample. - The YAML pane updates instantly. Pick a YAML indent of 2 or 4 spaces and optionally sort keys or quote every string.
- Edit the YAML directly if you like — the JSON side updates too.
- Click Copy or Download to save
data.yaml.
What does a JSON to YAML converter do?
It parses a JSON document and re-serialises the same data as YAML. Because YAML 1.2 is a superset of JSON, every JSON value has an exact YAML equivalent: objects become mappings, arrays become sequences (- item), and strings, numbers, booleans and null stay the same type. The result is typically 20–40% shorter and far easier to read and edit by hand, which is why YAML is the standard for Kubernetes, Docker Compose, GitHub Actions, Ansible and OpenAPI specs.
Example
This JSON:
{
"service": "api",
"replicas": 3,
"ports": [8080, 9090],
"env": {"LOG_LEVEL": "info"}
}
becomes this YAML:
service: api
replicas: 3
ports:
- 8080
- 9090
env:
LOG_LEVEL: info
How strings are quoted
The converter (powered by the widely used js-yaml library) only adds quotes where they are needed to keep the value a string. Values like "yes", "on", "123", "null" or "2024-01-01" are quoted because an unquoted yes would be read as a boolean by YAML 1.1 parsers (the famous “Norway problem”, where the country code NO turns into false). Strings containing : , # or leading spaces are also quoted. Multi-line strings are written as literal block scalars (|-) so line breaks stay readable. Enable Quote all strings if a downstream tool expects every string quoted.
JSON vs. YAML at a glance
| JSON | YAML | |
|---|---|---|
| Comments | Not allowed | # comment |
| Structure | Braces and brackets | Indentation |
| Quotes | Required on keys and strings | Usually optional |
| Multi-line strings | \n escapes | Block scalars | and > |
| Reuse | None | Anchors & and aliases * |
| Best for | APIs, data exchange | Human-edited config |
Tips for config files
Indentation in YAML must use spaces, never tabs. Two spaces is the convention for Kubernetes and most CI systems. After converting, you can add comments to explain settings — something JSON cannot hold. To go the other way, use the YAML to JSON converter; to tidy the JSON first, run it through the JSON Formatter.
Tools that pair well with the JSON to YAML
- JSON to CSV — Turn a JSON array into a spreadsheet-ready CSV.
- JSON to TypeScript — Paste a JSON sample — an API response, a config — and get ready-to-use TypeScript interfaces with nested types, optional properties and union types.
- CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
- JSON to Markdown Table — Turn API responses or LLM-generated JSON arrays into a clean, aligned Markdown table for READMEs, docs and pull requests.
Frequently asked questions
Is YAML a superset of JSON?
Why are some of my strings quoted in the YAML output?
"yes", "off", "0123" or "1.0" would be interpreted as booleans or numbers if left unquoted, so they are quoted to preserve them as strings.Can I convert JSON to YAML for Kubernetes?
kubectl get … -o json and you get YAML you can save as a manifest. Remove server-generated fields such as status, uid and resourceVersion before applying it again.