YAML to XML Converter
Convert YAML data to XML format
Tip: Paste your YAML data. If it's an array of objects, each object will become a row element.
Runs in your browserInput YAML
Convert YAML to XML in your browser
Paste YAML, open a .yaml or .yml file or drop it on the input window, and the XML appears as you type. Keys become elements, and the output starts with an XML declaration and is indented by two spaces. Copy it or download it as a .xml file.
The outer element is always <root>. A top-level mapping fills it with one element per key; a top-level list gives one <row> element per item.
YAML to XML example
Real output for a config with two services. Each list item is a <row>, and the ports list becomes two <ports> elements:
- name: api
image: nginx:1.27
ports:
- 8080
- 8443
env:
LOG_LEVEL: info
- name: worker
image: node:22
replicas: 3
env:
LOG_LEVEL: debug
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<name>api</name>
<image>nginx:1.27</image>
<ports>8080</ports>
<ports>8443</ports>
<env>
<LOG_LEVEL>info</LOG_LEVEL>
</env>
</row>
<row>
<name>worker</name>
<image>node:22</image>
<replicas>3</replicas>
<env>
<LOG_LEVEL>debug</LOG_LEVEL>
</env>
</row>
</root>
How YAML lists and mappings become elements
XML has elements, attributes and text, and each YAML structure takes one of them:
-
YAML
ports: [8080, 8443]XMLA list becomes repeated elements named after the key,
<ports>8080</ports><ports>8443</ports>, with no wrapper around them. -
YAML
env: {LOG_LEVEL: info}XMLA nested mapping becomes an element with its own child elements.
-
YAML
'@id': 7XMLA key starting with @ becomes an attribute of its parent,
id="7". Quote the key, because a plain YAML key cannot start with @. -
YAML
'#text': Ring twiceXMLA
#textkey becomes the element's own text, next to its attributes. -
YAML
note: ~XMLNull or an empty string gives a self-closing tag,
<note/>.
Tag names and special characters
Fixed for you
- A character not allowed in a tag name becomes
_:first namegives<first_name> - A name that starts with a digit or with
xmlgets a leading_:1stgives<_1st> &,<,>and"in values are escaped
Not done
- Keep types: numbers and booleans are written as plain text
- Keep YAML comments
- Rename
<root>or<row>, or add namespaces
Need the YAML back?
The XML to YAML converter turns attributes into '@' keys and repeated elements into lists.
YAML to XML questions
Click Open file and choose the .yaml or .yml file, or drop it on the input window. The XML shows up at once; Download saves it as a .xml file.
Items of a top-level list have no key, and every XML element needs a name, so each item is wrapped in <row>. Put the list under a key, such as services:, and the items are named after it.
Start the key with @ and quote it. Under book:, the keys '@id': bk101 and title: Salt Roads give <book id="bk101"> with a <title> inside.
No. More than one document separated by --- shows an error. Convert one document at a time.
No. Converting runs in your browser, and an opened file is read there too.