Paste YAML or upload a .yml file and get clean, well-formed XML. Choose the root element, how lists are written and which keys become attributes; YAML errors are shown with their exact line and column.
Last updated:
Converts automatically as you type. Comments are not kept.
Advertisement
Advertisement
How to use the YAML to XML Converter
Paste your YAML into the left box, upload a .yaml/.yml file, or click Sample.
Set the root element name, or tick the option to use a single top-level key as the root.
Choose how lists look: repeated elements, or wrapped in an item tag such as <item>.
Use attributes by starting a key with the prefix, for example @id: 7 becomes id="7".
Copy or download the XML. Fix any YAML errors shown with their line number first.
YAML to XML mapping rules
YAML
XML
name: Ann
<name>Ann</name>
user: {age: 30}
<user><age>30</age></user>
tags: [a, b] (repeat)
<tags>a</tags><tags>b</tags>
tags: [a, b] (wrap)
<tags><item>a</item><item>b</item></tags>
book: {"@id": 7, title: X}
<book id="7"><title>X</title></book>
price: {"@cur": EUR, "#text": 9.5}
<price cur="EUR">9.5</price>
manager: ~ or null
<manager/>
opened: 2019-04-01
<opened>2019-04-01</opened>
2024: yes, first name: Ann
<_2024>yes</_2024>, <first_name>Ann</first_name>
XML has no data types, so numbers, booleans and dates are written as their text form. Because YAML's @ is a reserved indicator, keys meant as attributes must be quoted: "@id": 7. Comments in the YAML are not part of the data model and are not carried over.
Why does XML need a root element?
A well-formed XML document has exactly one top-level element that contains everything else. YAML has no such rule, so the converter wraps your data in the root element name you choose (root by default). If your YAML already has a single top-level key, such as config:, tick "Use single top-level key as root" to use it directly instead of nesting it inside <root>.
Common YAML errors
Tabs for indentation: YAML only allows spaces. Pressing Tab in the input box inserts two spaces.
Inconsistent indentation: all keys at the same level must start in the same column.
Unquoted special characters: values starting with @, `, *, &, !, % or containing : should be quoted.
Duplicate keys in the same mapping are rejected, because the second one would silently overwrite the first.
Frequently asked questions
How is YAML mapped to XML?
Each key in a mapping becomes an element and its value becomes the element's content, so name: Ann becomes <name>Ann</name>. Nested mappings become nested elements, and everything is wrapped in a single root element because an XML document must have exactly one root.
How are YAML lists converted?
By default each list item repeats the parent element: tags: [a, b] becomes <tags>a</tags><tags>b</tags>, which is the most common XML convention. With the wrapped style you get <tags><item>a</item><item>b</item></tags>, using an item tag name you choose.
How do I create XML attributes from YAML?
Start the key with the attribute prefix, @ by default. For example user: {'@id': 7, name: Ann} produces <user id="7"><name>Ann</name></user>. A #text key sets the element's text alongside its attributes. Quote keys that start with @ in YAML, because @ is a reserved character.
What happens to keys that are not valid XML element names?
XML names cannot start with a digit or contain spaces and most punctuation. Such keys are adjusted automatically, for example 2024 becomes _2024 and first name becomes first_name, and the status line tells you how many were renamed.
Does it support anchors, aliases and multiple documents?
Yes. The YAML is parsed with js-yaml, so &anchors, *aliases, <<: merge keys, block scalars (| and >) and documents separated by --- are all resolved. Multiple documents are written as separate <document> elements inside the root.
Is my YAML uploaded?
No. Parsing and conversion run entirely in your browser; your configuration files never leave your device.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.