JSON to YAML Converter

Turn JSON into clean, human-friendly YAML for Kubernetes, Docker Compose, GitHub Actions or Ansible, with full control over indentation, style and quotes.

Runs in your browserNo sign-upNothing uploaded

JSON output

How to use the JSON to YAML

  1. Paste JSON into the left box or open a .json file.
  2. YAML appears on the right as you type.
  3. Choose the indent (2 or 4 spaces) and style: block (one key per line) or flow ({a: 1}/[x, y]) from a given nesting level.
  4. Pick a quoting style and tick Sort keys if you want alphabetical order.
  5. Copy or download the YAML. Invalid JSON is reported with its line, column and likely cause.

Why convert JSON to YAML?

JSON is ideal for machines and APIs, but YAML is easier for people to read and edit: no braces, no mandatory quotes and support for comments. Most infrastructure tools, including Kubernetes, Helm, Docker Compose, GitHub Actions, GitLab CI and Ansible, are configured in YAML, while the data you start from (API output, kubectl get -o json, Terraform state) is often JSON.

Block vs. flow style

Block style puts each key and list item on its own line and is the conventional choice for config files. Flow style uses inline {} and [], like JSON, and keeps short leaf structures compact. “Flow from level 2” keeps the top two levels in block style and inlines anything deeper, which works well for long lists of small objects such as ports or env vars.

Safe quoting

Strings that a YAML parser could misread are quoted automatically: values like 'no', 'on', '1.0', 'null', strings with a leading * or &, and strings containing : . Choose Always single or Always double if your style guide requires every string to be quoted.

YAML 1.1 vs 1.2 gotchas

This converter follows YAML 1.2, the current spec. Many older tools (PyYAML, Ruby's Psych, some Kubernetes and Ansible versions) still read YAML 1.1, where the rules differ:

  • The Norway problem: in YAML 1.1, country: no means false, so Norway's country code NO disappears. The same goes for yes, on, off, y and n. YAML 1.2 only treats true and false as booleans.
  • Octal numbers: 0755 is octal in 1.1 but a plain decimal in 1.2, which uses 0o755. Quote file modes to be safe.
  • Sexagesimal numbers: in 1.1, 22:30 can parse as the number 1350. Quote times and port mappings such as "8080:80".

The JSON → YAML direction quotes ambiguous strings ('no', 'on', 'y') automatically, so the YAML it produces reads the same in both versions.

Frequently asked questions

Is the conversion lossless?
Yes. Every JSON document is valid YAML 1.2, and the generated YAML parses back to exactly the same data. You can check by pressing Swap.
Why are some strings quoted and others not?
With Only when needed, quotes are added just where an unquoted value would change meaning, for example 'yes', '123' or strings with special characters. Everything else is left plain for readability.
Can I add comments to the output?
JSON has no comments, so there are none to convert, but you can add # comments to the YAML after copying it.
Does key order change?
No. Keys keep their JSON order unless you tick Sort keys.
Is my data private?
Yes. The converter runs in your browser and makes no network requests with your input.

Related tools