YAML to XML
Turn YAML into an XML document; keys starting with "@" become attributes and lists become repeated tags
Your data stays with you. Conversion happens inside the browser; nothing is sent to a server.
Did this tool do the job?
Thanks, your feedback came through.
How it works
When you have YAML — an application.yml, an Ansible vars file or an API example — and a system that only accepts XML, paste the YAML into the left pane. The XML appears on the right right away. If the YAML starts with a single top-level key, that key becomes the root element: text that begins with "order:" turns into an <order> document. If there are several top-level keys or a list at the top, everything is wrapped in the name from the "Root element name" box (root by default), because XML allows only one root. A key starting with @ becomes an attribute ("@id": 1024 → <order id="1024">) and a "#text" key becomes the element's own text. These are the reverse of the XML to YAML rules, so a document that goes back and forth between the two tools comes out the same. A list becomes a repeated tag: two entries under item give two <item> tags. An empty value ("cancel note:") becomes an empty element, <cancel_note/>. A name that is invalid in XML (a space, a leading digit) is not silently broken: it is adapted with underscores, and the result line tells you which key became what. Values keep their spelling: a price of 1.10 does not turn into 1.1, and a ZIP code like 01002 keeps its zero.
This tool is also known as yaml to xml, yaml to xml converter, convert yaml to xml, yml to xml, yaml to xml online.
What is YAML list?
In YAML, a list is a run of lines at the same indentation, each starting with "- "; a line like "- sku: US-11" shows that the entry itself is a mapping. A list can also be written on one line with square brackets: [a, b]. XML has no concept of an unnamed list; tags with the same name one after another play that role. That is why the list under "item:" becomes a series of repeated <item> tags, one per entry.
What is XML root element?
The root element is the single outermost tag that wraps all data in an XML document: <order> … </order>. XML does not accept two roots, so writing several top-level YAML keys side by side would produce a file no program can open. The tool therefore makes a single top-level key the root, or wraps everything in the name from the "Root element name" box. If the receiving system expects a specific root, such as Order, type that name.
What is the difference between YAML and XML?
YAML shows structure with indentation, is short and easy to edit by hand, and the parser guesses the type of unquoted values (number, true, null). XML wraps every value in tags, can carry attributes, can be validated with a schema (XSD) and has no types: every value is text. Nothing is lost going from YAML to XML, but two XML ideas need a YAML spelling: "@" for attributes and "#text" for mixed text. Enterprise integrations and older systems ask for XML; configuration files usually live in YAML.
Which YAML structure becomes which XML
The tool writes YAML to XML with the reverse of the XML to YAML rules, so a document that travels in both directions stays the same. A mapping (key: value) becomes child elements, a list becomes repeated sibling tags, a key starting with @ becomes an attribute and "#text" becomes the element's text. A list inside a list is wrapped in <item> tags, because XML has no unnamed lists.
The root rule: XML needs exactly one outermost element. If the YAML starts with one top-level key (whose value is not a list), that key is the root, and the result line says so. Otherwise the name in the "Root element name" box is used, and a list at the top level is written as <item> tags.
- "@id": 1024 → <order id="1024">
- item: [ {sku: US-11}, {sku: US-42} ] → two <item> tags
- cancel note: (empty) → <cancel_note/>
- "#text": Hello → the element text: <note>Hello</note>
The trap: values a YAML parser turns into numbers
A typical YAML parser turns an unquoted 1.10 into the number 1.1, 0501 into 501 and 1e3 into 1000; once written to XML, the original is gone. This tool only treats a value as a number when its spelling would not change, so 1.10, 0501, 1e3 and 2026-09-27 come out in the XML exactly as they were typed. XML has no types anyway — every value is text — so the right thing is to carry the text unchanged.
Unsupported features are reported, not skipped: anchors and aliases (&name, *name), type tags (!!str), complex keys starting with ?, and more than one document in the text (a second ---) give an error with the line number. Indentation errors come with a line number too; YAML does not allow tabs for indentation.
Frequently asked questions
How do I convert a YAML file to XML?
Open the .yml or .yaml file in a text editor, copy its content and paste it into the left pane on this page. The XML appears instantly on the right; copy it or download it as a .xml file. If the YAML has an error, the message gives the line number and what is wrong.
How do I write an XML attribute in YAML?
Put @ in front of the key name and write it in quotes: "@id": 7. The tool turns it into an id="7" attribute. If the element needs both an attribute and text, put the text under a "#text" key: note: {"@lang": en, "#text": Hello} → <note lang="en">Hello</note>.
Why is the root element name box sometimes ignored?
If the YAML starts with a single top-level key (for example only "order:"), that key already is the root element, so the box is not needed; the result line tells you this. The name in the box is used when the YAML starts with several top-level keys or with a list, because XML requires exactly one outermost element.
Is my data sent to a server?
No. Reading the YAML and writing the XML happen entirely in your browser, so passwords or addresses in your config never leave this page. After the page has loaded, it also works offline.