XML to YAML Converter
Convert XML data to YAML format
Tip: XML structure will be converted to YAML with improved readability.
Runs in your browserInput XML
Convert XML to YAML in your browser
Paste XML, open an .xml file or drop it on the input window, and the YAML appears as you type. Child elements become keys, repeated elements become a list, and nesting is shown by two-space indentation instead of closing tags. Copy the result or download it as a .yaml file.
The output starts with what is inside the root element, and long values stay on one line instead of being folded. If the XML is not well formed, the output window shows the parser's error instead.
XML to YAML example
Real output for a catalog of two books. The two <book> elements become list items, and @id and the prices are in quotes:
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="bk101">
<title>Paper Tigers</title>
<author>Rina Okafor</author>
<price>12.50</price>
</book>
<book id="bk102">
<title>Salt Roads</title>
<author>Jonas Hale</author>
<price>9.99</price>
</book>
</catalog>
book:
- '@id': bk101
title: Paper Tigers
author: Rina Okafor
price: '12.50'
- '@id': bk102
title: Salt Roads
author: Jonas Hale
price: '9.99'
Why some YAML values are in quotes
Every XML value is text. The quotes make sure a YAML reader loads it back as the same text and not as a number or a boolean:
-
XML
<price>12.50</price>YAMLBecomes
price: '12.50'. Without quotes YAML would read the number 12.5 and drop the zero. -
XML
<active>true</active>YAMLBecomes
active: 'true', which stays text instead of loading as a boolean. -
XML
<book id="bk101">YAMLAn attribute becomes a key starting with @. YAML does not allow a plain key to start with @, so it is written
'@id'. -
XML
<title>Paper Tigers</title>YAMLPlain text needs no quotes:
title: Paper Tigers. -
XML
<note/>YAMLAn empty element becomes an empty string,
note: ''.
What the YAML keeps from the XML
Kept
- Repeated elements, as a list under their name
- Text next to child elements or attributes, under a
'#text'key - Namespace prefixes, as part of the key:
dc:title
Dropped
- The root element's name
- Comments, processing instructions and the XML declaration
- A list for a single element: one
<book>becomes a mapping, not a list of one
Need the XML back?
The YAML to XML converter writes lists as repeated elements and '@' keys as attributes.
XML to YAML questions
Click Open file and choose the .xml file, or drop it on the input window. The YAML shows up at once; Download saves it as a .yaml file.
XML has no numbers, only text, and the converter keeps it that way. The quotes stop a YAML reader from turning 12.50 into 12.5 or 007 into 7; remove them in your file where you want real numbers.
An element that has attributes or child elements and also its own text, like <price currency="EUR">12.50</price>, becomes a mapping. Its text goes under '#text', next to '@currency'.
Yes, it is plain block-style YAML that any YAML 1.2 reader loads. Rename the '@' and '#text' keys first if your tool expects other names.
No. Converting runs in your browser, and an opened file is read there too.