Advertisement

JSON to YAML Converter

Convert JSON to clean, readable YAML for Kubernetes, Docker Compose, GitHub Actions or config files. Choose indentation, list style and key sorting.

YAML is the configuration language of Kubernetes, Docker Compose, GitHub Actions, Ansible and many CI tools, while APIs and generators usually produce JSON. YAML 1.2 accepts JSON syntax, but block-style YAML is often easier to edit. This converter rewrites JSON as idiomatic block-style YAML — no braces, no commas, quotes only where they are needed — and then reads the result back to check the parsed values.

How to use this tool

  1. Paste your JSON object or array.
  2. Pick 2-space indentation (the common default) or 4 spaces.
  3. Choose how lists are indented; both styles are valid YAML.
  4. Optionally sort keys or force double quotes on every string, then copy the YAML.

Formula

Objects → key: value lines; arrays → "- item" lines; nested values are indented one level. Strings are quoted only when the plain form would be read as something else.

A string needs quotes when it looks like a number, boolean or null ("123", "true", "null"), is a YAML 1.1 boolean such as "yes", "no", "on" or "off", or contains characters like ": " and " #". Multi-line strings use the | block style. Long lines are never folded, so values stay on one line.

Example

The sample service definition becomes 11 lines of YAML starting service: api, replicas: 3, debug: false. The env values stay strings: NODE_ENV: production is plain, and PORT: '8080' is quoted so it is not read as a number. ports turns into two "- 80" / "- 443" lines, owner becomes null, and the description containing ": " is wrapped in single quotes.

Frequently asked questions

Why are some values in quotes and others not?

YAML guesses types from plain text: 8080 is a number and yes may be a boolean. When the JSON value is a string that would be misread, it is quoted so it stays a string. Tick "double quotes" if your team prefers quoting all strings.

Is YAML 1.1 or 1.2 output?

The dumper targets YAML 1.2 and quotes legacy boolean-like strings such as yes and on. Other YAML 1.1 implicit types can differ between readers; the round-trip result applies to this tool’s parser.

Are key order and comments kept?

Key order is kept unless you choose sorting. JSON has no comments, so there are none to carry over; add them in the YAML afterwards with #.

Can I convert YAML back to JSON?

Yes, use a YAML to JSON converter. This check compares the YAML with the parsed JSON, not the original spelling. Duplicate keys, nonfinite numbers, underflow and unsafe integers are rejected; other decimals use JavaScript precision.

Sources

Last updated: 2026-10-30

Advertisement