JSON ⇄ YAML Converter
Convert between JSON and YAML formats
About this tool
JSON and YAML describe the same data in different syntax. JSON is strict, terse and machine-first, which is why APIs speak it; YAML uses indentation and supports comments, which is why Kubernetes, Docker Compose, Ansible and CI systems are configured with it.
This converter moves a document between the two in either direction. It parses the input properly, so a JSON syntax error is reported as an error instead of producing a silently truncated file.
When to use it
- Turning a Kubernetes or Docker Compose manifest into JSON for a tool that only accepts JSON
- Converting an API response into YAML to paste into a config file
- Checking that a YAML document actually parses before you deploy it
- Producing readable, indented JSON from a minified API payload
Worked example
Input
{
"name": "John Doe",
"age": 30,
"hobbies": ["reading", "coding"]
}
Output
name: John Doe
age: 30
hobbies:
- reading
- coding
Both directions are lossless for the data types JSON and YAML share, and the converter indents with two spaces.
Frequently asked questions
Is the conversion lossless?
For the data types the two formats share, yes. The one thing JSON cannot represent is a YAML comment, so comments and anchors are dropped when you convert YAML to JSON.
Why do JSON numbers change when I convert to YAML?
Very large integers can lose precision when a parser treats them as floating point. The converter dumps YAML with reference expansion disabled and a wide line width, but it cannot exceed the precision of the underlying JSON parser.
Does this tool send my document anywhere?
No. Both the JSON and YAML parsers run entirely in your browser, so configuration files with secrets in them never leave your machine.