JSON to YAML Converter
Convert JSON to YAML instantly with correct indentation, quoting and nesting. Paste JSON, get valid YAML for Docker, Kubernetes or CI config. Nothing is uploaded.
Worked examples
- A small config object
The simplest case: flat keys become one YAML line each; strings that look like versions stay unquoted only when YAML can read them back unambiguously.
- Nested objects and an array
Shows how nesting becomes indentation and arrays become block sequences — the two things people check when moving Docker or Kubernetes config.
- Strings that need quoting
A colon inside a string, a numeric-looking string and an empty string all require quotes in YAML, otherwise they change meaning when read back.
What this converter does
JSON and YAML describe the same data — objects, arrays, strings, numbers, booleans and null — with different syntax. JSON uses braces, brackets and quotes; YAML uses indentation and a few punctuation rules. This tool parses your JSON and writes it back out as YAML, so the meaning is identical and only the formatting changes.
When you need it
- Turning an API response or a
package.json-style object into a Docker Compose, Kubernetes, GitHub Actions or CI config file. - Moving settings between tools that only accept one of the two formats.
- Reading a large JSON blob more comfortably: YAML strips the braces and quotes, which makes nested data easier to scan.
Rules the converter applies
- Nesting becomes indentation. Each level of a JSON object is indented by the number of spaces you choose (2 by default).
- Arrays become block sequences.
[1, 2]is written as two lines starting with-. - Strings are quoted only when they have to be. YAML would otherwise read
1.0as a number anda: bas a nested key, so those strings are wrapped in quotes to keep them as text. The tool also quotes strings that YAML 1.1 parsers (PyYAML, Ruby, older Kubernetes and Docker Compose tooling) read specially:yes,no,on,off,y,n, dates like2024-01-01, and numbers written with underscores such as1_000. YAML 1.2 parsers would accept those bare, but quoting them is safe for both. - Key order is preserved. Nothing is sorted.
- Invalid JSON stops the conversion and shows the parser's error and position instead of guessing.
JSON and YAML side by side
| JSON | YAML | Note |
|---|---|---|
| {"a": 1} | a: 1 | Objects become key–value lines |
| [1, 2] | - 1- 2 | Arrays become dash lists |
| "yes" | "yes" | Kept quoted: bare yes would read as a boolean |
| null | null | Also written as ~ by some tools |
| 1e3 | 1000 | Numbers are normalised when re-serialised |
YAML 1.2 is designed as a superset of JSON: every JSON document is already valid YAML, so this direction keeps all structure and string content. The only values that change are numbers, which pass through JavaScript number formatting (an integer beyond about 9 × 10^15 is rounded). The reverse direction (YAML to JSON) drops comments and anchors.
Things to check after converting
- YAML files that will be read by another program are sensitive to indentation: mixing 2- and 4-space indents in one file is the most common cause of "mapping values are not allowed here" errors.
- Comments cannot be converted because JSON has none; add them by hand afterwards.
- Very long strings are written on one line (line wrapping is disabled) so nothing changes inside them.
Frequently asked questions
- Is my JSON uploaded anywhere?
- No. The conversion runs entirely in your browser; nothing is sent to a server.
- Why are some strings quoted in the YAML output?
- YAML treats values like 1.0, true, null and anything containing a colon specially, and older YAML 1.1 parsers (PyYAML, Ruby, some Kubernetes tooling) also read yes, no, on, off and dates specially. Quoting keeps them as the exact strings your JSON contained.
- Does the output preserve key order?
- Yes. Keys are written in the order they appear in the JSON object.
- Can I choose the indentation?
- Yes — 2 spaces is the YAML convention and the default; 4 is common in some codebases.