SmartQueryTools

Convert YAML to XML Online

Convert YAML files to XML directly in your browser. Download a structured XML document with one element per row — no upload required.

About converting YAML to XML

YAML and XML both describe structured data, but they sit in different ecosystems. Converting a YAML list to XML helps when a Java, .NET or enterprise integration system expects XML input, or when you want to transform records with XSLT. The converter targets record-style YAML, not YAML that mirrors a specific XML schema.

The output always has the same shape. A <data> root holds one <row> per YAML record, and each key becomes a child element with the value as text. Keys are cleaned into valid element names. Hyphens, dots, spaces and other punctuation become underscores, so a key like max-retries becomes <max_retries>. A key that starts with a digit gets an underscore in front.

The output is one level deep. Nested YAML mappings are not turned into nested XML elements; they are written as JSON text inside one element. Flatten them first with the Flatten YAML tool. A YAML list inside a record is written the same way, as a JSON array such as ["a","b"]. Null values and missing keys become empty elements. Comments are dropped, and there is no way to mark a value as an XML attribute.

Worked example

A small orders export with an ID, a customer name, a date, an amount (one missing) and a true/false flag, converted with the default settings.

Input (YAML)

- order_id: 1001
  customer: Acme Ltd
  order_date: '2026-03-02'
  amount: 249.5
  shipped: true
- order_id: 1002
  customer: Brightside Co
  order_date: '2026-03-02'
  amount: 1200
  shipped: false
- order_id: 1003
  customer: Acme Ltd
  order_date: '2026-03-05'
  amount: 89.99
  shipped: true
- order_id: 1004
  customer: Northwind
  order_date: '2026-03-07'
  amount: null
  shipped: false

Output (XML)

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <row>
    <order_id>1001</order_id>
    <customer>Acme Ltd</customer>
    <order_date>2026-03-02</order_date>
    <amount>249.5</amount>
    <shipped>true</shipped>
  </row>
  <row>
    <order_id>1002</order_id>
    <customer>Brightside Co</customer>
    <order_date>2026-03-02</order_date>
    <amount>1200</amount>
    <shipped>false</shipped>
  </row>
  <row>
    <order_id>1003</order_id>
    <customer>Acme Ltd</customer>
    <order_date>2026-03-05</order_date>
    <amount>89.99</amount>
    <shipped>true</shipped>
  </row>
  <row>
    <order_id>1004</order_id>
    <customer>Northwind</customer>
    <order_date>2026-03-07</order_date>
    <amount></amount>
    <shipped>false</shipped>
  </row>
</data>

What changes when you convert YAML to XML

  • The document has an XML declaration, a <data> root and one <row> element per record.
  • Each key becomes a child element, such as <order_id>1001</order_id>.
  • Keys with characters that XML names cannot contain are cleaned, so max-retries becomes max_retries.
  • null and missing keys become empty elements, like <amount></amount> for order 1004.
  • &, <, >, quotes and apostrophes in values are escaped as XML entities.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Frequently Asked Questions

Can nested YAML become nested XML elements?

No. The converter writes one flat level of elements per record. Flatten the YAML first so nested keys become separate columns, or build nested XML with an XSLT step afterwards.

Can I make some YAML keys into XML attributes?

No. Every key becomes a child element. An XSLT transform or a small script can move chosen elements into attributes after conversion.

Why did my key names change?

The converter keeps only letters, digits and underscores in element names. Spaces, hyphens, dots and other punctuation become underscores, and a name starting with a digit gets an underscore prefix. Hyphens and dots are legal in XML, but replacing everything else keeps the output well-formed for any key.

Related Tools