JSON to YAML Converter

Convert JSON into readable YAML with two-space indentation, ready for config files.

Loading tool…

About the JSON to YAML

YAML 1.2 is a superset of JSON, so every JSON document has an exact YAML equivalent. The output uses block style with two-space indentation, the format expected by Kubernetes manifests, Docker Compose, GitHub Actions workflows and OpenAPI specs. Long strings are not folded.

Strings are quoted only when they would otherwise be read as another type or break the syntax. "yes", "on", "1.0", "null" and strings starting with * or & keep their quotes, which avoids the well-known YAML 1.1 “Norway problem” where NO turns into false. Multi-line strings are written as literal | blocks.

Conversion uses the js-yaml library loaded from this site and runs in your browser. Key order is preserved. JSON has no comments, so there are none to carry over.

Example: {"ports": [{"name": "http", "port": 8080}]} becomes a ports: key followed by a list item - name: http with port: 8080 indented under it. Empty arrays and objects are written as [] and {} in flow style, and null stays null.

How to use it

  1. Paste JSON or open a .json file.
  2. Check the YAML in the output pane.
  3. Copy it or download converted.yaml.

Frequently asked questions

Why are some strings quoted in the YAML?
Without quotes YAML would read them as a boolean, number or null (for example "yes" or "1.0"), which would change your data.
Can I use the output in Kubernetes?
Yes. It is standard block-style YAML. For multiple resources, convert each and join them with --- lines.
Is YAML really a superset of JSON?
For YAML 1.2, yes: any JSON file is valid YAML with the same meaning.

Related tools