What JSON to YAML does
JSON to YAML reads JSON and writes it as YAML. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.
JSON to YAML examples
The built-in sample
Input
{"name":"Ada Lovelace","active":true,"tags":["math","code"],"address":{"city":"London"}}Output
name: Ada Lovelace
active: true
tags:
- math
- code
address:
city: London
This is the input that the Load sample button fills in.
Strings that YAML would misread
Input
{"msg":"line one\nline two","ver":"1.10","on":"yes","n":null,"e":"","list":[]}Output
msg: |-
line one
line two
ver: '1.10'
'on': 'yes'
'n': null
e: ''
list: []
The string "1.10" is quoted so that it is not read back as the number 1.1, and "yes" is quoted too. A string with a line break becomes a block scalar (|-). The keys on and n are quoted because older YAML parsers read them as booleans.
Each output was produced by running this tool on the input above it.
How it works
Reading JSON. The input is parsed as JSON (RFC 8259). If it is not valid, the conversion stops and the error shows the line and column of the problem.
Writing YAML. The result is written with js-yaml using two-space indentation. Strings are quoted only when they would otherwise be read as another type, such as a number or boolean.
Details and limits
- Values are carried across without losing anything in ordinary data; the points above list the cases the two formats handle differently.
- Strings longer than 80 characters are folded onto several lines with
>-. That is still the same string when it is parsed again. - Key order is kept. An empty array is written as
[]and an empty object as{}. - JSON has no comments or anchors, so the YAML never contains any.
- Input that is not valid JSON stops the tool, and the status line shows where the problem is. The JSON Validator page lists the usual causes.
Questions
Is my data uploaded when I use JSON to YAML?
No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.
What does JSON to YAML do?
JSON to YAML reads JSON and writes it as YAML. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.
Are there any limits I should know about?
Strings longer than 80 characters are folded onto several lines with >-. That is still the same string when it is parsed again. Key order is kept. An empty array is written as [] and an empty object as {}.
Is there a size limit?
There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.
Does it work on phones, and is it free?
Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.