YAML Anchors and Aliases Explainer

Parse anchors (&name) and aliases (*name) in YAML, count definitions and references, expand everything into complete YAML, and compare original, expanded and side-by-side views.

FreeOnline Tool
Loading…

How to Use

Paste YAML that uses anchors (&name) and aliases (*name) into the box and it is parsed automatically, showing the number of anchor definitions and alias references. A table below lists each anchor's definition line, reference lines and a value preview; undefined references are highlighted in red. Switch between the 'Original YAML', 'Expanded YAML' and 'Side-by-side' tabs to see the highlighted source, the fully expanded document, or both together. Load the 'Docker Compose Sample' or 'CI/CD Pipeline Sample' to try it instantly.

Features

  • Counts anchor definitions and alias references automatically
  • Table view of each anchor with definition line, usage lines and value preview
  • Flags undefined alias references to catch typos
  • Highlighted original view plus a fully expanded YAML view
  • Three viewing modes: original, expanded and side-by-side

Use Cases

Decode Docker Compose x- extensions
Paste a docker-compose.yml using anchors like &default-logging to see how services share one config block
Debug CI/CD pipeline configs
Expand a GitLab CI pipeline that uses <<: *default-env to locate variable or cache reference errors
Learn YAML anchor syntax
Understand how & anchors map to * aliases by comparing the original and expanded views side by side
Review and migrate configs
Expand anchors in configs written by others so every line can be verified or migrated to tooling without anchor support

FAQ

What are anchors and aliases?
An anchor (&name) marks a value and an alias (*name) reuses it elsewhere. The <<: *name merge key spreads anchor content into the current mapping, the main way YAML reuses config
Which syntax is supported?
&name definitions, *name references and <<: *name merge keys are all parsed, counted and located in the table
Why does it report 'Undefined reference'?
It means a *name is used without a matching &name definition earlier in the file, usually a typo or a missing anchor, so the expanded output may be incomplete
Can I use the expanded YAML directly?
Yes. The expanded view replaces every alias with its anchor content in place, ready to read or to paste into tools without anchor support