Skip to content
ToolPlankDEV
JSON Tools
100% In-Browser Execution

Updated:

XML to YAML Converter

Paste XML and get YAML as you type. This xml to yaml converter lets you choose how attributes, repeated elements, text and namespaces are mapped, keeps 007 as text, points to the line and column of any error and lists what was dropped. Nothing is uploaded.

Options:

XML

Input
0 chars · 0 lines

YAML

Ready
Processing in browser...
0 chars · 0 linesUpdates as you type

Mapping notes

How attributes, lists and dropped parts were handled appears here once there is a result.

Processed on your device. Your text is not sent to our servers.

More free tools you may need next.

Quick Guide

How to use XML to YAML

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Paste or open your XML

    Paste the XML into the left box, press Paste, or press Upload and choose an .xml file. Sample loads a Maven pom.xml fragment. Spring beans, Android strings and RSS item load other common shapes.

  2. 02

    Read the YAML and the mapping notes

    The YAML appears on the right as you type. If the XML has a mistake, the message gives the line and column. The Mapping notes panel counts attributes, lists, dropped comments and anything else that changed shape.

  3. 03

    Choose the mapping

    Pick the attribute prefix, the key for element text, whether a lone element is a list, whether numbers and booleans are detected, whether namespace prefixes stay, and the indent.

  4. 04

    Copy or download

    Press Copy to paste the YAML into your project, or Download to save it as converted.yaml. Use the swap button to turn YAML back into XML.

How to convert XML to YAML

XML and YAML both describe nested data, but they do not have the same parts. XML has elements, attributes, text and comments. YAML has maps, lists and values. To convert xml to yaml, a tool has to decide where each XML part goes, and those decisions are the whole job.

This converter makes the decisions visible and lets you change them. Take this small file:

xml
<server port="8080" secure="true">
  <host>app.example.com</host>
  <user>ana</user>
  <user>bo</user>
  <build>007</build>
</server>

With the default settings it writes:

yaml
server:
  "@port": 8080
  "@secure": true
  host: app.example.com
  user:
    - ana
    - bo
  build: "007"

The two attributes became keys that start with @. The two user elements became a list. The port became a number, and 007 stayed text so it keeps its zeros.

How XML attributes are written in YAML

YAML has no attributes, so each attribute becomes a key inside the map of its element. A prefix keeps attributes apart from child elements. Without it, an element with an id attribute and an id child would collide.

  • Prefix @ is the usual convention. YAML puts quotes around keys that start with @, so you will see "@port".
  • Prefix _ and prefix - need no quotes, which reads cleaner in a config file.
  • No prefix writes attributes as plain keys. If a child element has the same name, an underscore is added to the second key and the notes say so.

An element that has attributes and also text keeps its text under a key you can name. The default is #text, and you can change it to value or anything else. YAML to XML reads the same prefix and text key, so the conversion can go back.

What happens to repeated elements

A YAML map cannot hold the same key twice, so elements with the same name next to each other become one key with a list. A single element stays a plain value, which is why the same file can give a value in one place and a list in another.

If you want predictable shapes, set Repeated elements to Always a list. Then even one item is written as a list:

yaml
list:
  item:
    - one

When same-name elements are not side by side, for example b, c, b, they are grouped under one key at the position of the first one. The notes tell you when that reordering happened. Order between different names is kept.

Numbers, booleans and values like 007

XML stores only text. With Detect numbers and booleans, a plain number is written as a number and true or false as a boolean. A number is detected only when it prints back exactly as it was typed, so 8080 and 2.5 become numbers, while 007, 1.50 and 12345678901234567890 stay text.

Text that YAML would misread is quoted. Older YAML 1.1 parsers, still common in Kubernetes and Compose tooling, read yes, no, on and off as booleans, so those words are written as "yes" and "no". Choose Keep everything as text to quote every value that could be read as something else.

Namespaces, CDATA, comments and DOCTYPE

Namespace prefixes are kept by default, so s:Body stays s:Body and the xmlns declaration is written as an attribute. Strip prefixes removes both, which gives shorter keys when you do not need the namespace:

yaml
Envelope:
  Body:
    GetPrice:
      Item: Apple

That example is a SOAP envelope. Stripping prefixes can merge two names that differed only by prefix, and the notes warn you.

  • CDATA sections are read as ordinary text and written as a YAML string.
  • Comments and processing instructions are dropped, because the mapping has no place for them. The notes count them.
  • A DOCTYPE is skipped. Nothing is fetched from it, and custom entities defined in it are not expanded. An unknown entity is reported as an error.
  • Text between child elements, as in <p>Hello <b>big</b> world</p>, is joined and written under the text key. The position of the child inside the sentence is lost, and the notes list this as mixed content.

XML to YAML for Maven, Spring and Android files

Build and config files are the usual reason to convert. A pom.xml becomes a nested YAML map with a dependency list. A Spring beans file becomes a list of beans with attribute keys for id and class. An Android strings.xml gives a string list in which each item has a name attribute and the text under the text key. The samples under the input box load each of these.

The result is a faithful picture of the XML, not a file for a particular tool. A YAML file for Spring Boot or Kubernetes has its own structure, so expect to reshape the output by hand. The mapping notes show you what the converter had to decide.

Errors and limits

The reader is strict. A closing tag that does not match, an attribute without quotes, an ampersand that is not part of an entity or a second root element stops the conversion, and the message names the line and column and says what to fix. It reads XML 1.0 text. It does not validate against a schema or DTD, run XSLT or query with XPath.

Nesting deeper than 400 levels is refused. Very large files take time, so for files of many megabytes a command-line tool is a better fit.

Privacy

Config files often hold hostnames, passwords and tokens. The conversion runs in your browser and the XML is not uploaded. The Privacy Policy explains what the site stores. Replace real secrets with placeholders before you share a file.

For other formats, see YAML to JSON, JSON to YAML and Properties to YAML.

Frequently Asked Questions

Technical Q&A for XML to YAML

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the XML into the left box and the YAML appears on the right. Check the Mapping notes, then press Copy or Download. Choose the attribute prefix and list rules first if your target tool expects a certain shape.

As keys inside the map of their element, with a prefix such as @ so they do not clash with child elements. You can switch the prefix to _ or -, or turn it off.

Elements with the same name become one key with a list of values. A single element stays a plain value unless you set Repeated elements to Always a list.

No. Comments are dropped because YAML written from XML data has no place for them, and the notes tell you how many were dropped.

XML marks data with tags and attributes and allows comments, namespaces and mixed text. YAML uses indentation, maps and lists and is shorter to read. XML can hold things YAML cannot, such as attributes and text mixed with elements.

Because a value with leading zeros is not a number you can write back exactly. The converter keeps it as text so no zeros are lost.

Press Upload and choose your .xml file, or paste its contents. The file is read in your browser and the result is ready to download as converted.yaml.

Yes. YML and YAML are the same format. Press Download and rename the file to end in .yml if your project uses that extension.

Yes. Prefixes are kept by default, or you can strip them and the xmlns attributes for shorter keys. The notes warn if two names would end up sharing a key.

No. The conversion runs in your browser, so the file stays on your device. A DOCTYPE in the file is skipped and nothing is fetched from it.