PicoToolkit
Extracted data:
View Settings
Applies to real TAB characters.
0 characters
0 without spaces
0 words
0 lines
IndexValue
No matching items found
Spotted a bug or have an idea for a new feature? Let us know here »

XML to YAML Converter

Convert any XML into reader-friendly YAML format with PicoToolkit

Convert any XML into reader-friendly YAML format with PicoToolkit

Quickly turn XML into clean YAML you can read, edit, and copy. The converter is browser-based — paste your XML, set indentation, convert, then copy the result.

How to use

  • Paste your XML into the input area (copy & paste only — no file upload).
  • Choose indentation (spaces) if you need custom formatting.
  • Click Convert. The YAML appears in the output panel — use Copy to grab the result.
  • Use the YAML directly in configs, scripts, or downstream tools.
  • usage of the tool

Conversion rules (what to expect)

  • Top-level children of the XML root become top-level YAML keys (the root element is not preserved).
  • Elements that contain only text become scalar values (key: text).
  • Empty elements and self-closing tags become empty mappings (key: {}).
  • Attributes are ignored by the YAML output (they do not become keys or values).
  • Repeated sibling elements with the same name become YAML lists.
  • Whitespace-only element content is preserved as a string.
  • HTML/XML entities (e.g. <, >, &) are decoded into characters in text nodes.
  • CDATA sections and mixed or complex nodes are represented as mappings ({} or child mappings) depending on presence of child elements.
  • Namespace prefixes are preserved in element names (for example x:item becomes the key "x:item").

Examples (copyable)

1) Simple elements and empty tags

Input XML:
<root>
  <a id="1" />
  <b id="2">text</b>
  <c>text</c>
</root>

Output YAML:
a: {}
b: text
c: text

2) Element with attributes only

Input XML:
<root>
  <item count="10" active="true" price="19.99" code="0010"/>
</root>

Output YAML:
item: {}

3) Repeated elements → list

Input XML:
<root>
  <tag>one</tag>
  <tag>two</tag>
  <tag>three</tag>
</root>

Output YAML:
tag:
  - one
  - two
  - three

4) Repeated complex elements → list of mappings

Input XML:
<root>
  <user id="u1"><name>Alice</name></user>
  <user id="u2"><name>Bob</name></user>
</root>

Output YAML:
user:
  - name: Alice
  - name: Bob

5) Empty, explicit-empty and whitespace-only nodes

Input XML:
<root>
  <e1/>
  <e2></e2>
  <e3>   </e3>
  <e4><child/></e4>
</root>

Output YAML:
e1: {}
e2: {}
e3: '   '
e4:
  child: {}

6) Entities and CDATA

Input XML:
<root>
  <plain>&lt;b&gt;bold&lt;/b&gt; &amp; stuff</plain>
  <cdata><![CDATA[<b>bold</b> & stuff]]></cdata>
</root>

Output YAML:
plain: <b>bold</b> & stuff
cdata: {}

7) Mixed inline content (text + inline tags)

Input XML:
<root>
  <p>Hello <b>world</b> and <i>friends</i>!</p>
</root>

Output YAML:
p:
  b: world
  i: friends

8) Namespaces and prefixed elements

Input XML:
<root xmlns="urn:default" xmlns:x="urn:x" xmlns:y="urn:y">
  <x:item y:id="123">value</x:item>
  <item x:flag="1">v2</item>
</root>

Output YAML:
x:item: value
item: v2

example 1a

example 1b

Tips & edge cases

  • If you need attributes preserved, export the XML first into a format that keeps attributes as elements (this tool drops attributes).
  • Mixed content (text plus child elements) will prioritize child elements in YAML; surrounding plain text may be omitted.
  • Large or deeply nested XML is supported, but use increased indentation carefully to keep readability.
  • Namespaces are kept as part of the element name (prefix:key).
  • Use the indentation option to match your project's YAML style.

Related tools

FAQ

How do attributes appear in YAML?

Attributes are ignored by this converter. If an element has attributes but no child elements or text, the element becomes an empty mapping ({}). If it has text content, the element becomes the scalar text value.

Does the tool preserve namespaces?

Yes — namespace prefixes are preserved as part of the element name (for example x:item becomes the key "x:item").

Are entities and CDATA handled differently?

Entity references in text nodes are decoded (e.g. &amp;lt; → &lt;). CDATA sections are treated as complex content and are represented as mappings ({} or child mappings) depending on whether they include child elements.

Can I upload files?

No — this converter works via copy & paste in the browser input area only.

Can I change output indentation?

Yes — use the indentation control to set the number of spaces for YAML output to match your project's style.

PicoToolkit evolves fast. Stay ahead.

Get early access to new tools, features, and productivity upgrades.

We email you occasionally. You can unsubscribe anytime.
© PicoToolkit 2022-2026 All rights reserved. Before using this website read and accept terms of use and privacy policy. Icons by Icons8