Paste XML or open an .xml file and get tidy YAML instantly. Attributes become @keys, mixed text becomes #text, repeated tags become lists, and any well-formedness error is pointed out by line and column.
Last updated:
Parsed with your browser's own XML parser; nothing is uploaded. Drop an .xml file on the input. Tip: Ctrl + Enter converts.
Advertisement
Advertisement
How to use the XML to YAML Converter
Paste your XML into the left box, drop an .xml file on it, or press Open .xml. A sample catalog is loaded to start.
Choose the options: indentation, attribute prefix, text key and how repeated elements are listed.
Read the YAML on the right. With Live update on it refreshes as you type.
Fix any error: invalid XML shows the line and column; press Show in input to jump to it.
Copy or download the result as a .yaml file.
How XML maps to YAML
XML
YAML
Rule
<name>Ada</name>
name: Ada
Text-only element becomes a key: value pair
<item id="7"/>
item: "@id": 7
Attributes get the @ prefix
<price cur="USD">9.5</price>
price: "@cur": USD "#text": 9.5
Text beside attributes goes under #text
<tag>a</tag><tag>b</tag>
tag: - a - b
Repeated siblings become a list
<empty/>
empty:
Empty element is null
<![CDATA[a & b]]>
a & b
CDATA is read as plain text
Keys that start with @ or # are quoted in the YAML because those characters have a special meaning at the start of a plain YAML scalar.
Common XML errors
Mismatched tags: every <tag> needs a matching </tag> with the same case, or must be self-closed as <tag/>.
Unescaped ampersands: write & instead of a bare &, or wrap the text in <![CDATA[ … ]]>.
More than one root element: an XML document has exactly one top-level element. Wrap several in a parent such as <items>.
Unquoted attributes:id=7 is HTML style; XML needs id="7".
Each attribute becomes a key that starts with the attribute prefix, "@" by default, so <price currency="USD"> gives "@currency: USD" under price. You can change the prefix (for example to "_" or nothing) or tick Ignore attributes to leave them out.
What is the #text key?
When an element has both attributes or child elements and its own text, the text cannot be the element's value on its own, so it is stored under the text key, "#text" by default. An element that only contains text is written as a simple key: value pair.
How are repeated elements handled?
Sibling elements with the same name are grouped into a YAML list in document order. A single element stays a plain mapping unless you choose Always a list, which makes every element a list so the structure is the same no matter how many items there are.
Are numbers and booleans converted?
With Detect numbers & booleans on, text such as 14, 189.99 or true is written without quotes so YAML reads it as a number or boolean. Values with leading zeros like 02134 stay strings. Turn the option off to keep every value as a string.
What happens to empty elements like <discontinued/>?
An empty element without attributes becomes a key with an empty (null) value, written as "discontinued:". If it has attributes, only the @attribute keys are written.
Why do some values have quotes?
YAML would misread certain plain strings, for example yes, no, on, off, null, values that look like numbers or dates, or text containing ": " or " #". These are quoted so the YAML means exactly what the XML said.
Is my XML uploaded?
No. The file is parsed by your browser's built-in XML parser and converted in this page, so nothing leaves 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.