
Your XML shows up here as you type.
Conversion happens in your browser. Your YAML is never uploaded.
How YAML maps to XML
YAML has maps, lists and values. XML has elements, attributes and text. Here is how each piece of your YAML turns into XML. The key names under "Attribute prefix" and "Text key" can be changed in More options.
| YAML | XML | What happens |
|---|---|---|
title: Dune | <title>Dune</title> | A key with a value becomes an element with text. |
book: "@id": bk1 title: Dune | <book id="bk1"> <title>Dune</title> </book> | Keys starting with @ become attributes on the parent tag. |
price: "@currency": USD "#text": 9.99 | <price currency="USD">9.99</price> | #text sets the element's own text, so it can have attributes and a value. |
tag: - fiction - classic | <tag>fiction</tag> <tag>classic</tag> | Lists repeat the tag once per item. Choose "Wrap items in a tag" to get <tag><item>…</item></tag> instead. |
script: "#cdata": "if (a < b) go()" | <script><![CDATA[if (a < b) go()]]></script> | #cdata wraps the value in a CDATA section instead of escaping it. |
notes: | <notes/> | Empty values and null become empty elements. |
first name: Ann | <first_name>Ann</first_name> | Keys that aren't legal XML names are fixed, and the tool tells you which ones it renamed. |
"As written" vs. "YAML types"
XML stores everything as text, so by default the converter keeps each value exactly as you typed it. 007 stays 007, 1.50 keeps its trailing zero, and yes stays yes. That is usually what you want when the XML feeds another system that does its own parsing.
Switch to "YAML types" to read values the way a YAML 1.2 parser would. Numbers are normalized (1.50 becomes 1.5, 0x1F becomes 31), true and false are recognized, and dates are written in ISO format. In both modes, anchors, aliases and << merge keys are expanded, and comments are dropped.
Questions
Do I need to put quotes around @ and #text keys?
Not here. In standard YAML, @ is a reserved character and # starts a comment, so @id: 5 is invalid and #text: hi is silently ignored. This tool quotes those keys for you before parsing, and tells you how many it fixed. If you plan to use the same YAML somewhere else, quote them yourself: "@id": 5. You can turn this off in More options.
What happens with multiple YAML documents in one file?
If the file contains several documents separated by ---, each one becomes a <document> element inside the root tag, in the same order.
Why is my root tag different from the one I typed?
When your YAML has exactly one top-level key that holds a map, such as catalog:, that key becomes the root tag. This avoids an extra wrapper around documents that already have a natural root. Turn off "Use a single top-level key as the root" in More options to always use your root tag.
What does the error about tabs mean?
YAML doesn't allow tab characters for indentation. If your file was indented with tabs, use the "Replace tabs with spaces" button that appears with the error, and the file converts as normal.
Can it handle large files?
Yes. Files of several megabytes convert in your browser. Very large results are shown without color highlighting to keep the page responsive, but Copy and Download always give you the full XML.
Is my data uploaded anywhere?
No. The YAML parser runs in your browser, and nothing you paste or open is sent to a server.
