How to use the JSON to YAML
- Paste the JSON you want as YAML, for example a Kubernetes manifest from kubectl -o json.
- Pick the indent width (2 spaces is the common convention).
- Review quoted values; they are quoted on purpose (see below).
- Copy or download the .yaml file.
Worked example
A service config with values YAML could misread
Input
{"service":"api","port":8080,"debug":false,"hosts":["a.example.com","b.example.com"],"version":"1.10","enabled":"yes"}YAML
service: api port: 8080 debug: false hosts: - a.example.com - b.example.com version: "1.10" enabled: "yes"
version and enabled are strings in the JSON. Unquoted, 1.10 would load as the number 1.1, and yes as a boolean in YAML 1.1 parsers, so they are quoted. Quote style may be single or double.
JSON and YAML side by side
| Concept | JSON | YAML |
|---|---|---|
| Object | {"a": 1} | a: 1 |
| List | [1, 2] | - 1 then - 2 on separate lines |
| String | Always quoted | Quoted only when needed |
| Comments | Not allowed | # comment |
| Multi-line text | \n escapes | Block scalars | and > |
| Reuse | Not possible | Anchors & and aliases * |
The strings YAML gets wrong
YAML infers types from bare text, which is where most config bugs come from. yes, no, on and off are booleans in YAML 1.1 (still used by many tools); 0755 can be read as octal; 1.10 becomes 1.1; a country code NO becomes false. The converter quotes such strings so they round-trip as strings.
Indentation and tabs
YAML forbids tab characters for indentation. If you edit the output, keep spaces only, and keep list dashes aligned under their parent key's indentation level or one step in – both are valid, mixing them in one list is not.
Comments cannot be generated because JSON has none; add them after converting.
JSON to YAML FAQ
Is JSON valid YAML?
Yes, YAML 1.2 is a superset of JSON, so most YAML parsers accept JSON directly. Converting is about readability: block-style YAML is easier to edit and diff by hand.
Why are some values quoted in my YAML output?
Without quotes they would load as a different type, such as yes becoming true or 1.10 becoming 1.1. Quoting keeps them strings, matching the original JSON.
Can I convert a Kubernetes JSON manifest to YAML?
Yes. Paste the output of kubectl get <resource> -o json and copy the YAML. Remove status and metadata fields like uid and resourceVersion before re-applying it.
Does the converter keep key order?
Yes, keys appear in the same order as in the JSON.
How are empty objects and arrays written?
As flow style: {} and []. Block style has no way to write an empty collection.

