{jsonbody.com}

JSON to YAML Converter

Convert JSON to YAML and YAML to JSON online for free. Set the indent, catch syntax errors instantly, and copy or download the result. Runs in your browser.

What this JSON to YAML converter does

This tool translates data between JSON and YAML in both directions. Paste JSON and you get YAML as you type. Switch the tab, or press the swap button, and YAML goes back to JSON. Syntax errors appear straight away, so you can fix a missing comma or a bad indent before the file reaches a deployment.

The two formats describe the same structures: maps, lists, strings, numbers, booleans and null. JSON is strict and easy for programs to produce, which is why APIs use it. YAML is lighter to read and edit by hand, which is why Kubernetes, Docker Compose, GitHub Actions and Ansible use it for configuration.

How to convert JSON to YAML

  • Paste your JSON into the left pane, or open a file from your computer.
  • Choose an indent of 2 or 4 spaces. Most YAML tools expect 2.
  • Copy the YAML from the right pane or download it as a file.
  • To go the other way, select the YAML to JSON tab. Your input is never sent to a server.

Example: a Kubernetes-style config

The same deployment settings in both formats. Notice that YAML drops the braces, the quotes around keys and the commas, and uses indentation to show nesting.

JSON input and YAML output
{ "kind": "Deployment", "spec": { "replicas": 3, "ports": [80, 443] } }

kind: Deployment
spec:
  replicas: 3
  ports:
    - 80
    - 443

Things to watch for in YAML

Indentation carries meaning in YAML, and tabs are not allowed for it. A line that is one space out of place can change the structure of the document without any error, so converting to JSON is a quick way to see what a parser really reads.

  • Comments written with # are lost in the YAML to JSON direction, because JSON has no comments.
  • Strings such as no, on or 1.10 can be read as other types by some parsers. Quote them to be safe.
  • YAML anchors and aliases are expanded into full copies of the data when converted to JSON.

Frequently Asked Questions

Is YAML a superset of JSON?

Since YAML 1.2, almost every valid JSON document is also valid YAML. A YAML parser can usually read JSON directly, but the reverse is not true because JSON has no comments, anchors or indentation-based blocks.

Why did my YAML comments disappear?

JSON has no comment syntax, so comments cannot survive the conversion to JSON. Keep the YAML file as your source if the comments matter.

Should I use 2 or 4 spaces of indent?

Two spaces is the common convention for Kubernetes, Compose and CI files. Either is valid as long as you stay consistent within a file.

Is my configuration uploaded anywhere?

No. The conversion runs in your browser with a JavaScript library, so secrets in your config are not sent to jsonbody.com.