YAML ⇄ JSON

Convert YAML to JSON or JSON to YAML, with clear errors, anchors expanded and warnings for values other YAML readers see differently.

Runs in your browser. Nothing is uploaded.

Updated

YAMLRuns in your browser · up to 20 MB
Your text stays on this device. No upload required.

How to use YAML ⇄ JSON

  1. Choose YAML → JSON or JSON → YAML.
  2. Paste the text or open a file; the result updates as you type.
  3. Read any notes, then copy or download the result.

YAML ⇄ JSON at a glance

Typical use: Turn a Docker Compose or Kubernetes file into JSON for jq, or a JSON config into YAML.

Runs in your browser; nothing is uploaded. Converts with YAML 1.2; comments can’t be kept in JSON.

When to use YAML ⇄ JSON

YAML and JSON hold the same kind of data: maps of keys and values, lists, text, numbers, true/false and null. YAML is easier for people to write (Docker Compose, Kubernetes, GitHub Actions, OpenAPI); JSON is what most programs, APIs and tools like jq expect.

This page converts either way as you type, shows exactly where a YAML file is broken, and points out values that different YAML readers understand differently.

YAML ⇄ JSON examples

Check a Docker Compose file. Paste it in: anchors like &defaults and <<: *defaults are expanded, so the JSON shows each service’s full settings. A tab used for indenting or a key written twice is shown with its line and column.

Kubernetes manifests. A file with several documents separated by --- becomes a JSON array with one item for each, ready for jq.

Write a config file from JSON. Choose JSON → YAML, paste an API response or a package.json, and download clean YAML with 2-space indents.

The “Norway problem” and other surprises

YAML 1.1, still used by PyYAML, Ruby and some Go programs, reads unquoted no, yes, on and off as true or false, 010 as the octal number 8, 1:30 as 90 and 2026-11-30 as a date. YAML 1.2 (this page, yq, most new tools) keeps them as text or plain numbers. So the country code NO can become false in one program and stay "NO" in another.

This page converts with YAML 1.2 and adds a note for every such value with its line. When writing YAML, it quotes them by default so every reader agrees.

Prefer the terminal?

The same in a terminal with yq (mikefarah/yq, version 4):

yq -o=json '.' docker-compose.yml > docker-compose.json

For JSON to YAML: yq -P '.' package.json. With Python: python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin), indent=2))' < config.yaml — but PyYAML reads YAML 1.1, so no, on and 010 come out as false, true and 8 (see below).

Frequently asked questions

Is my file uploaded?

No. The conversion runs in your browser, so configuration files with passwords or keys stay on your device.

Are comments kept?

Not in JSON, which has no comments; the page says when it left some out. Going from JSON to YAML there are no comments to keep.

What happens to anchors, aliases and <<?

They are expanded: every alias becomes a full copy of what it points to, and << merges the keys, with keys written next to it winning. JSON has no way to share parts, so the JSON can be longer than the YAML. Files whose aliases would expand to a huge size are stopped.

Are big numbers and key order kept?

Yes. Integers of any length, like 20-digit IDs, are copied digit for digit, and keys stay in the order they were written unless you tick “Sort keys A–Z”.

Why is my YAML invalid?

The most common causes are a tab used for indenting (YAML allows only spaces), a key written twice in the same map, a missing space after a colon, and text with a colon or # that needs quotes. The page shows the line and column of the first problem.