YAML to XML
Turn YAML into XML that any parser accepts. Mappings become nested elements, lists become repeated elements named after their key, keys starting with @ become attributes, multi-line strings keep their line breaks, and null values can be empty elements, xsi:nil or left out. Keys that are not valid XML names are adjusted and all text is escaped.
- Runs in your browser
- No sign-up
- Free to use
How to use YAML to XML
- Paste YAML or open a .yml file.
- Set the root and list item names if you like.
- Choose how null values are written.
- Copy or download the XML.
YAML to XML features
Natural structure
Mappings to elements, lists to repeated elements.
Attributes
Keys like "@version" become XML attributes.
Valid names
Keys with spaces or leading digits are made legal.
Escaping
&, < and > in values are always escaped.
Null options
Empty element, xsi:nil with namespace, or omitted.
Precise errors
Invalid YAML is reported with line and column.
When to use YAML to XML
- Feeding YAML configuration into a system that reads XML.
- Generating XML test fixtures from readable YAML.
- Converting Kubernetes or CI data for XML-based tools.
- Producing XML for XSLT transformations.
YAML to XML FAQ
How are lists converted?
A list under the key hosts becomes several <hosts> elements, one per item. A list at the top level uses the item name you choose.
How do I create attributes?
Write keys starting with @, quoted in YAML: "@version": "2" becomes version="2" on the parent element.
What is the root element?
When the YAML has a single top-level key, that key becomes the root. Otherwise a root element named root (or your choice) wraps everything.
What about anchors and aliases?
They are resolved by the YAML parser, so the XML contains the referenced data in full.
Can I convert XML to YAML?
Yes, with the XML to YAML tool.
Is my data uploaded?
No. The conversion runs in your browser.
Writing YAML data as XML
YAML is popular for configuration because it is concise and readable, while XML remains the expected format for many enterprise systems, document pipelines and older integrations. Converting between them requires decisions that the YAML itself does not make, such as what the root element is called and how list items are named.
The converter uses the common conventions. A YAML mapping becomes an element whose children are its keys; a list becomes a sequence of elements that repeat the key name, so hosts: [a, b] turns into two <hosts> elements; scalar values become element text. When the document has exactly one top-level key, it becomes the root element; otherwise a root element wraps the content.
XML distinguishes attributes from child elements, which YAML cannot express directly. Keys that start with an @ sign are therefore written as attributes of their parent, and a #text key provides text content next to attributes. This matches the convention used by the XML to YAML and XML to JSON tools, so round trips keep their shape.
XML names are stricter than YAML keys: they cannot contain spaces or most punctuation and cannot start with a digit. Such keys are adjusted with underscores, and the number of adjusted keys is reported. Text is escaped so that values containing <, > or & never break the document.
The YAML is parsed with js-yaml, which resolves anchors and aliases and reports syntax errors with line and column. Null values have three possible representations, from empty elements to the schema-aware xsi:nil attribute, whose namespace is declared automatically.