JSON to YAML converter
Paste JSON and get clean YAML back, with tricky strings quoted so they keep their meaning.
Runs entirely in your browser
- Input
- 0
- Output
- 0
- Change
- 0%
Input up to about 10 MB. It converts data only; JSON has no comments, so none can appear in the YAML.
How to convert JSON to YAML
- Paste your JSON into the box, or press Insert a sample.
- Choose a 2 or 4 space indent, and switch on Sort keys to list every mapping alphabetically.
- If the JSON is invalid you see the line and column. Otherwise copy the YAML or download it as a
.yamlfile.
Turning JSON into readable YAML
YAML is largely a more human-friendly way to write the same data JSON holds. Braces and quotes give way to indentation and plain words, which is why configuration for Kubernetes, Compose and CI systems is usually written in it. Starting from JSON, such as an API response or a generated manifest, the conversion is mechanical, but one detail needs care: YAML decides a value's type from how it looks.
In YAML a bare true is a boolean, null is null and 1.0 is a number. A JSON string that happens to look like one of those, such as "null", "1.0" or "0x1F", must be quoted in the YAML or it will change type when read. The converter quotes exactly those, plus empty strings and text that starts with symbols that have a meaning in YAML, and then checks the output by reading it back.
Multi-line text becomes a literal block, which is far easier to read than a long string with \n escapes. Empty objects and arrays are written as {} and []. Because JSON has no comments, the YAML starts without any; you can add your own afterwards.
Tips
- To go from YAML back to JSON, use YAML to JSON.
- Validate and pretty-print the JSON first with the JSON formatter if you are unsure it is well-formed.
- Want a spreadsheet instead? JSON to CSV flattens an array of objects.
Questions
Is my JSON uploaded?
No. It is parsed and converted by code that runs in your browser, so nothing you paste leaves your device.
Why are some strings in quotes?
A plain yes, null, 1.0, 012 or 0x1F would be read back as a boolean, null or number, not as the string you had. The converter quotes those strings (and empty strings) so the YAML means what the JSON meant.
How do I know the YAML matches the JSON?
After converting, the page reads the YAML back with a YAML 1.2 parser and compares it with your data. If they ever differ, a notice appears above the result.
How are multi-line strings written?
A string containing line breaks is written as a block scalar (|), which keeps it readable. Single-line text stays on one line unless you tick the wrap option.
Does it change the order of my keys?
Keys keep their order, with one JavaScript quirk: keys that are whole numbers, such as "1", are listed first, in numeric order. Tick Sort keys to order every level alphabetically.
What about large numbers?
Integers larger than 9,007,199,254,740,991 are written exactly as typed, not rounded. Decimal numbers with more than about 17 significant digits are rounded to the nearest value a double can hold.