YAML to XML — Convert YAML Configuration to XML Markup in Your Browser
Convert YAML data to XML markup. Configurable root element, attribute heuristics, pretty-print. Runs entirely client-side — no uploads, no limits.
YAML is the format humans write and XML is the format enterprise systems expect, and the gap between them is the reason this tool exists. A DevOps team defines infrastructure in YAML (Kubernetes manifests, Ansible playbooks, Terraform variables) because YAML is compact and readable. A legacy monitoring system consumes that same data as XML because the monitoring system was built in the era when XML was the universal interchange format. The conversion from YAML to XML bridges that gap: it takes a YAML structure that was written for human readability and produces an XML document that any XML-aware system can consume.
The conversion uses JSON as an intermediary — YAML resolves to JSON, and JSON serialises to XML — so the attribute convention is the same as the one in the JSON-to-XML tool. YAML keys starting with @ become XML attributes, and regular keys become child elements. This convention is not part of any standard, but it is the de facto approach across the npm and Python ecosystems, and it is the right default for portability. YAML sequences become repeated XML elements, which is the only natural mapping: a YAML list of items has no equivalent in XML’s tree model except a repeating element with the same tag name at the same depth.
For a final hand-off: if the XML output is going into a SOAP service or an XML-RPC endpoint, confirm the expected root element name before converting — SOAP envelopes require a specific wrapper structure that the tool’s generic root element may not match. If the XML needs to conform to a schema, use the JSON Schema Generator (from the intermediate JSON representation) to produce a JSON Schema, then map the constraints to XSD by hand. If the output needs to include CDATA sections for embedded markup, add the <![CDATA[...]]> wrapping after conversion — the tool emits plain text content and does not detect when a value contains XML or HTML that needs CDATA encapsulation.
How to use
Paste your YAML data
Drop a YAML string or file into the input. The parser reads YAML 1.2 and resolves anchors, aliases, and merge keys. The resolved data structure is converted to XML with configurable element naming.
Configure XML output
Set the root element name (default `<root>`), choose indentation (2 or 4 spaces), and toggle the `@`-key-to-attribute convention. YAML keys starting with `@` become XML attributes on their parent element.
Copy or download the XML
Copy the formatted XML to your clipboard, or download as an .xml file. The output includes the standard `<?xml version="1.0" encoding="UTF-8"?>` declaration and is valid XML 1.0.
Frequently asked
How does the converter decide the XML element names?
YAML mapping keys become XML element names directly. Keys that start with a digit, contain spaces, or include characters not valid in XML element names are sanitised with underscore prefixes. The `@key` convention turns the YAML key `@type` into an XML attribute `type="..."` on the parent element.
What happens to YAML sequences (arrays) in the XML output?
YAML sequences (items prefixed with `-`) become repeated XML sibling elements. A YAML `ports: [80, 443]` becomes `<ports>80</ports><ports>443</ports>`. The wrapping element takes the sequence's key name, and each item becomes a child element with the same tag.
Are YAML anchors and aliases preserved as XML references?
No. Anchors and aliases are resolved during YAML parsing and expanded inline in the XML output. The XML contains the fully expanded data. YAML's anchor/alias system has no direct XML equivalent — XInclude or entity references would be the XML approach but they are not generated.
How does the converter handle YAML boolean and null values?
YAML `true` and `false` (and their aliases `yes`/`no`/`on`/`off`) become XML text content `true` and `false`. YAML `null` (and `~` and empty values) become either a self-closing empty element `<key/>` or a comment `<!-- null -->` depending on the null-handling setting.
Limitations
- No XML Schema or DTD generationThe converter produces XML data, not XML validation rules. For a schema, feed the YAML through the JSON Schema Generator first (YAML to JSON, then JSON to Schema) and manually write the equivalent XSD constraints.
- Scalar YAML produces a single-element XML documentA YAML file containing only a scalar value (a single string, number, or boolean) produces an XML document with a root element containing that scalar. The converter expects structured mapping or sequence data.
- No CDATA wrapping for embedded contentYAML values that contain HTML or XML content are emitted as regular text, not wrapped in CDATA sections. If the output XML is consumed by a parser that requires CDATA-wrapped fragments, add the wrapping manually.
Platform notes
- macOS
- For CLI work, `yq -p yaml -o xml input.yaml` handles the conversion. The browser tool is the right pick for one-off YAML-to-XML conversion when yq is not installed.
- Web
- All YAML parsing and XML generation runs client-side. No data is uploaded. Works offline after the page loads for secure configuration conversion.