TXT · Text & Data tools

XML to YAML Converter

Input · XML
Output · YAML
0 Bin0 Bout0lines in0keysEmptyXML
Go to the full Data Format Converter

XML to YAML

Convert XML to YAML. Paste XML on the left; the YAML output builds on the right as you type.

<order id="1042">
  <status>shipped</status>
  <items>pen</items>
  <items>notebook</items>
</order>

becomes

order:
  "@_id": "1042"
  status: shipped
  items:
    - pen
    - notebook

The id attribute becomes a quoted "@_id" key, since a bare @ at the start of a YAML key has special meaning in some YAML processors and this converter quotes it defensively. The two <items> elements collapse into one items list, with pen and notebook as entries.

Strings, not numbers

XML has no type system beyond text, so <count>3</count> produces the string "3" in the YAML output, not the bare number 3. If you need real YAML numbers, convert through JSON first and adjust the field there, or accept the quoted string if your downstream YAML parser coerces it anyway.

Quoting choices

The YAML serializer quotes a value only when leaving it bare would change its meaning, such as a string that looks like a number, or contains a colon followed by a space. Most plain element text ends up unquoted; attribute-derived keys like @_id are quoted because of the leading @, not because of their value.

When to use this over XML to JSON

Pick this pair when the destination is a YAML config file or a CI pipeline definition that expects YAML directly. If you’re feeding a script that calls JSON.parse or an API that expects a JSON body, use XML to JSON instead; both start from the same parsed XML.

Frequently Asked Questions

As a key named @_ followed by the attribute name, quoted since YAML keys starting with @ need quotes. <item id="7"> becomes "@_id": "7" nested under item.

A tag name that repeats under the same parent becomes a YAML list under that key, with one list item per element, the same array rule XML to JSON uses before the value becomes YAML.

No. XML element text stays a string all the way through, so <count>3</count> becomes count: "3" in quotes, not the bare number 3, since XML never told the converter it was numeric.

The input pane shows the parser's line and column for the failure, most often an unclosed tag, more than one root element, or an unescaped & in text content.

The text becomes a #text key alongside the child element keys, matching the same convention XML to JSON uses before the value is written out as YAML.

Jump straight to a conversion

Full Data Format Converter tool

Explore Our Tools

Browse all tools