Convert YAML Anchors & Aliases to JSON (Merge Keys Explained)
YAML's &anchor / *alias syntax exists so you don't have to repeat yourself — but JSON has no such reuse mechanism, so converting to JSON means the DRY structure has to be expanded out into literal, duplicated data.
The real behavior
How the expansion actually works: an &name anchor captures whatever value follows it at parse time. Referencing it later with *name deep-clones that captured value into the new location (via a JSON round-trip clone) — so the output has independent, duplicated copies, not shared references. A <<: *name merge key is different again: it copies the anchor's keys directly into the current mapping, and any key written after the merge in the same block overrides the merged-in value — which is why, in the example below, production's own timeout: 60 wins over the default's timeout: 30.
YAML ↔ JSON Converter
Convert between YAML and JSON formats. Supports anchors, aliases, merge keys, multi-document YAML, and common tags.
YAML ↔ JSON Converter: Convert between YAML and JSON formats. Supports anchors, aliases, merge keys, multi-document YAML, and common tags. Runs entirely in your browser — paste your input, get instant output, nothing is uploaded.
What Is a YAML to JSON Converter?
A YAML to JSON converter transforms data between two of the most widely used data serialization formats. YAML (YAML Ain't Markup Language) is a human-friendly format popular for configuration files, while JSON (JavaScript Object Notation) is the standard for APIs and data interchange. Converting between them is one of the most common tasks in modern development.
YAML uses indentation-based structure with minimal syntax — no braces, brackets, or quotes required for most values. This makes it easier to read and write by hand, which is why it's the format of choice for Docker Compose, Kubernetes manifests, GitHub Actions, Ansible playbooks, and CI/CD pipelines. JSON, on the other hand, uses explicit delimiters and is natively supported by every programming language, making it ideal for API payloads, configuration storage, and data processing.
This converter handles bidirectional YAML ↔ JSON conversion with support for advanced YAML features: anchors and aliases (&anchor / *alias), merge keys (<<:), multi-document YAML, type tags (!!str, !!int), and complex nested structures. The built-in YAML parser runs entirely in your browser — no data leaves your machine.
How to Convert Between YAML and JSON
- Enter your data — Paste YAML in the left panel or JSON in the right panel. Both panels are editable text areas with monospace formatting.
- Click the conversion button — Click "YAML → JSON" to convert YAML to formatted JSON, or "JSON → YAML" to convert JSON to clean YAML output.
- Review the output — The converted result appears in the opposite panel. JSON output is formatted with 2-space indentation. YAML output uses standard 2-space nesting.
- Copy the result — Click the "Copy" button above either panel to copy the content to your clipboard.
- Iterate and edit — Both panels remain editable, so you can modify either format and re-convert as needed. Error messages appear clearly when the input has syntax issues.
Key Features
- Bidirectional conversion — Convert YAML to JSON and JSON to YAML with dedicated buttons. Edit either side and convert in any direction.
- Anchors and aliases — Full support for YAML anchors (
&name) and aliases (*name), which define reusable data blocks. Anchors are resolved and expanded in the JSON output. - Merge keys — Supports the
<<:merge key syntax for inheriting and overriding properties from anchored blocks, commonly used in Docker Compose and CI/CD configs. - Multi-document YAML — Handles YAML files containing multiple documents separated by
---. Multiple documents are converted to a JSON array. - Type tags — Supports YAML type tags like
!!str,!!int,!!float,!!bool,!!null,!!seq, and!!mapfor explicit type casting. - 100% client-side — Built-in YAML parser and serializer run entirely in your browser. No external libraries loaded, no server requests, no data uploaded.
Common Use Cases
- Kubernetes and Docker — Convert Kubernetes manifests and Docker Compose files from YAML to JSON for programmatic manipulation, validation with JSON Schema, or use with tools that only accept JSON.
- CI/CD pipeline debugging — Convert GitHub Actions workflows, GitLab CI, or CircleCI configs to JSON to inspect their structure, verify nesting, or process them with scripts.
- API development — Convert YAML-defined API schemas (OpenAPI/Swagger) to JSON format, or convert JSON API responses to YAML for more readable documentation.
- Configuration migration — Migrate configuration files between tools that use different formats. For example, converting a YAML config to JSON for a Node.js application or vice versa.
- Learning and debugging — Use the converter to understand how YAML indentation maps to JSON nesting, verify that your YAML produces the expected structure, or debug anchor/alias resolution.
Frequently Asked Questions
🔒 This tool runs entirely in your browser. No data is sent to any server.