YAML to JSON

Paste YAML and get the equivalent JSON, with anchors expanded and errors pinned to a line.

Tier 0 · browser · unlimited
99 characters
Output
{
  "defaults": {
    "retries": 3,
    "timeout": 30
  },
  "prod": {
    "<<": {
      "retries": 3,
      "timeout": 30
    },
    "timeout": 60,
    "regions": [
      "us-east",
      "eu-west"
    ]
  }
}

Why convert YAML to JSON

Configuration is written in YAML because it is pleasant to edit, but many tools and APIs only accept JSON: REST endpoints, JSON Schema validators, jq pipelines and JavaScript code. Converting also exposes what a YAML file really means, because indentation mistakes and implicit types become visible as JSON structure.

This converter follows YAML 1.2, the current specification. Under 1.2 only true and false are booleans, so yes and no remain strings. Older YAML 1.1 tools treat them as booleans; if a value matters, quote it in the source.

Worked example

defaults: &d
  retries: 3
  timeout: 30
prod:
  <<: *d
  timeout: 60

becomes {"defaults": {"retries": 3, "timeout": 30}, "prod": {"retries": 3, "timeout": 60}} (formatted on several lines on the page). The anchor &d and the merge key << are resolved, and prod keeps its own timeout.

How this works

The page parses the YAML with the eemeli/yaml library under the YAML 1.2.2 core schema, expands anchors, aliases and merge keys, and writes the resulting value as JSON with the indentation you choose. Comments disappear because JSON has no comments. When the YAML is invalid, the parser's line and column are shown. Only the first document of a multi-document file is converted. Use JSON to YAML for the reverse. Everything runs in this tab.

Frequently asked

Why did yes stay a string?

YAML 1.2, the current spec, only treats true and false as booleans. YAML 1.1 tools read yes/no as booleans.

Are comments kept?

No. JSON has no comments, so they are dropped.

My file has several documents (---). What happens?

Only the first document is converted. Paste the others separately.

Is my YAML uploaded?

No. Parsing runs in your browser.

Sources

Reviewed Oct 17, 2026 · test vectors fixtures/dev/yaml-to-json/