YAML to XML

Turn YAML into well-formed XML.

Reverse
Input
YAML input
Output
Result
Options

Spaces per level of nesting.

About this tool


YAML to XML has to supply what YAML lacks: a single root element, and a name for every sequence entry. Both are configurable here, and the output is guaranteed well-formed regardless of what your keys look like.

The usual driver is an older system, SOAP endpoints, enterprise middleware, or tooling with an XML-only import path.

How to use it

  1. Paste or upload YAMLDrop a .yaml file onto the input pane, use the file picker, or paste the text directly.
  2. Adjust the options if neededThe defaults suit most input. Open Options to change how values are interpreted or formatted.
  3. ConvertPress Convert to XML, or use Ctrl+Enter (Cmd+Enter on macOS).
  4. Read any warningsWarnings explain anything that could not be represented exactly in the target format.
  5. Copy or downloadCopy the result, or download it as a .xml file.

Worked examples


Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.

YAML to XML

Input

host: localhost
ports:
  - 80
  - 443

Output

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <host>localhost</host>
  <ports>
    <item>80</item>
    <item>443</item>
  </ports>
</root>

The sequence entries each need an element name; <item> is the default.

What to watch for


The details that decide whether a conversion is correct, and where information can be lost without any error being raised.

A root element is always added
XML permits exactly one top-level element, so the YAML document is wrapped, by default in <root>. Sequence entries additionally need element names, since XML has no anonymous list; each becomes <item> unless renamed.
Keys that are not valid XML names are rewritten
An XML element name must begin with a letter or underscore and cannot contain spaces. A key like "2024" becomes <_2024> and "first name" becomes <first_name>. The rewrite is reported and is not reversible, so converting back will not restore the original key text.
null becomes an empty element
YAML null has no XML counterpart, so it is written as an empty element, which is indistinguishable from an empty string. Schemas that need real nullability use xsi:nil, which this converter does not add automatically.
Comments and anchors are lost
YAML comments are dropped, and anchors and aliases are expanded into full copies before serialisation. The data is correct but repeated, and the shared relationship is no longer visible.

Limitations


  • Keys that are not valid XML names are rewritten, which cannot be reversed.
  • null and empty string both become an empty element.
  • Comments and anchors do not survive.
  • Output is well-formed but not validated against a schema.
  • Processing happens in your browser, so very large inputs are bounded by available memory. Files above roughly 10 MB are handled but will feel slower, and multi-hundred-megabyte files are better suited to a command-line tool.

Questions


Can I control the element names?
Yes. The root element name and the name used for sequence entries are both configurable in Options.
Can I produce attributes rather than child elements?
Yes, by prefixing a YAML key with @_. That matches the convention the XML to YAML converter uses, so the pair round-trips.