XML to YAML Converter

Paste an XML document and read it as indented YAML, without angle brackets or closing tags. The conversion runs on your device, so configuration and payloads remain confidential.

XML → YAML

Input

Settings

History

Load from URL

When YAML is the better view of XML

XML is precise but noisy: every value is wrapped in an opening and a closing tag, and deep nesting quickly becomes hard to follow. YAML shows the same tree with indentation alone, which makes it a good format for:

  • Reviewing a large SOAP or XML API response during debugging.
  • Migrating an XML config (Spring beans, a Maven settings file, an old .config) to a YAML-based tool such as Spring Boot’s application.yml or Ansible.
  • Writing documentation where readers should see the data, not the markup.

If your next step is code rather than a person, XML to JSON uses the same rules and gives you JSON instead.

How elements and attributes appear in YAML

The document becomes a mapping with one key, the root element’s name. Underneath it:

  • Child elements become nested keys; text-only children become simple key: value lines.
  • Attributes become keys starting with @. Because @ is reserved in YAML, these keys are always quoted: "@id": ord_8f2k1.
  • Text that shares an element with attributes or children is stored under "#text", and CDATA under "#cdata" — again quoted, since # would otherwise start a comment.
  • Elements with the same name are collected into a YAML list (- items), even if other elements appear between them.
  • Empty elements become empty strings, written "".
  • Multi-line text and CDATA become literal block scalars, so a SQL statement or a script keeps its lines.

Namespace prefixes stay in key names, and entity references such as & are decoded to the characters they stand for.

Detect numbers and booleans

With the option off (the default), every value is a string. YAML would normally guess types from unquoted text, so the converter quotes any string a YAML reader might mistype: "8080", "true", "NO", "0755". That guarantees the YAML means exactly what the XML said.

Switch on Detect numbers and booleans to write true numbers and booleans instead. Only exact matches convert: 8080 becomes an unquoted number and true a boolean, while values whose text would change — 0755, 1.50, very long integers — remain quoted strings. Text such as NO is never treated as a boolean.

Losses and limits

Comments, processing instructions and the DOCTYPE are removed, and an info message counts them. In mixed content, where text and child elements alternate, the text fragments are trimmed and joined, and their position among the children is not kept. An element that appears once is a mapping, while one that repeats is a list, so a schema with optional repetition can produce either shape.

Parsing is strict: malformed XML is reported with a line and column rather than half-converted. Nothing leaves the browser.

Examples

Order document

Attribute keys are quoted, the repeated item elements form a list, and the CDATA text appears under “#cdata”.

Input
<order id="ord_8f2k1" status="paid">
  <customer vip="true">Aisha Tan</customer>
  <item sku="KB-104" qty="1">Mechanical keyboard</item>
  <item sku="MS-220" qty="2">Wireless mouse</item>
  <note><![CDATA[Leave at <front> door]]></note>
</order>
Output
order:
  "@id": ord_8f2k1
  "@status": paid
  customer:
    "@vip": "true"
    "#text": Aisha Tan
  item:
    - "@sku": KB-104
      "@qty": "1"
      "#text": Mechanical keyboard
    - "@sku": MS-220
      "@qty": "2"
      "#text": Wireless mouse
  note:
    "#cdata": Leave at <front> door
Open this example in the tool

Legacy app settings with types

port and ttl become numbers and tls a boolean, while 0644 and NO stay quoted strings because they are not exact numbers or booleans.

Input
<configuration>
  <server port="8080" tls="true">api.internal</server>
  <cache>
    <ttl>300</ttl>
    <mode>0644</mode>
    <region>NO</region>
  </cache>
</configuration>
Output
configuration:
  server:
    "@port": 8080
    "@tls": true
    "#text": api.internal
  cache:
    ttl: 300
    mode: "0644"
    region: "NO"
Open this example in the tool

Common errors and how to fix them

ErrorCauseFix
The closing tag </a> is never finished — expected '>'
Explained
The document is truncated or a closing tag lost its final bracket.Complete the tag on the reported line.
Expected </item> to close <item> opened at line 3, found </items>
Explained
Opening and closing tag names differ, often a typo or a missing closing tag.Make the closing tag match the element it closes.
Unescaped '&' — it must start an entity reference like &amp; or &#38;
Explained
A literal ampersand appears in text, for example in a URL.Escape it as &.

Frequently asked questions

Why are the @ and # keys in quotes?

In YAML, @ is a reserved character and # starts a comment, so keys beginning with them must be quoted to stay valid.

Why does "8080" have quotes in the YAML?

Without type detection every XML value is a string, and quoting keeps a YAML parser from turning it into a number. Enable Detect numbers and booleans if you want real numbers.

Can I convert the YAML back to XML?

Convert it to JSON first with the YAML to JSON converter, then use JSON to XML, which understands the same @ and #text convention.

Is XML namespace information kept?

Prefixes stay in the key names and xmlns declarations become @xmlns keys, but namespace URIs are not resolved or validated.

Related tools