YAML to XML Converter
Convert YAML configuration or data to XML: maps become nested elements, lists repeat their parent element, and keys that start with @ become attributes.
YAML to XML Converter
Runs in your browser — nothing you enter is uploaded or stored.
Scratchpad auto-saved
How it works — in four simple steps
No signup and nothing to install — it all runs in your browser.
Add your YAML
Paste it into the left box, press Open file, or drag a .yaml file onto it. Sample loads a realistic example.
Set the options
Adjust the options above the boxes — the output updates instantly as you change them.
Check the result
Read the status line: it reports rows, keys and any value that couldn't be represented in XML.
Copy or download
Copy the XML or download it as a .xml file. Nothing was uploaded at any point.
Quote keys that start with @ in YAML ("@id": 7) — they become XML attributes.
Features
Your element names
Set the root element and the name used for each array item, and invalid characters are fixed for you so the XML stays well-formed.
Attributes kept, clearly marked
XML attributes become keys with an @ prefix (or _ / - / none), so they never collide with child elements of the same name.
Declaration on demand
Include or omit the <?xml version="1.0" encoding="UTF-8"?> line.
CDATA when you want it
Text containing < or & can be wrapped in CDATA sections instead of being escaped.
Private by design
Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.
About the YAML to XML Converter
YAML and XML are both hierarchical, which makes this conversion predictable. Every YAML mapping key becomes an element and its value becomes the element's content; a nested mapping becomes nested elements. A YAML sequence under a key repeats that key's element once per entry, so ports: [80, 443] becomes two <ports> elements — the same rule XML-to-YAML uses in reverse.
The YAML is read with a block-style parser that understands indentation, comments (#), quoted strings, inline lists and maps ([a, b], {k: v}), multi-document files separated by ---, and block scalars (| keeps line breaks, > folds them). Anchors, aliases and custom tags (&base, *base, !!binary) aren't supported — expand them first if your file uses them.
Because XML needs a single root, a YAML file with one top-level key uses that key as the root; anything else is wrapped in the root element you choose. YAML comments are not carried over: they belong to the YAML syntax, not to the data, so no parser exposes them.
Examples
A service configuration with a nested map, a list of ports and a multi-line message.
service:
"@version": 2
name: billing-api
replicas: 3
ports:
- 8080
- 8443
env:
LOG_LEVEL: info
REGION: ap-south-1
motd: |
Maintenance window:
Sundays 02:00-03:00 IST<?xml version="1.0" encoding="UTF-8"?>
<service version="2">
<name>billing-api</name>
<replicas>3</replicas>
<ports>8080</ports>
<ports>8443</ports>
<env>
<LOG_LEVEL>info</LOG_LEVEL>
<REGION>ap-south-1</REGION>
</env>
<motd>Maintenance window:
Sundays 02:00-03:00 IST
</motd>
</service>This output was produced by the converter on this page with the default options — load it with the “Service config” preset above and change any option to see the effect.
How YAML maps to XML
| In YAML | Becomes in XML |
|---|---|
name: app | <name>app</name> |
| Nested mapping | nested elements |
ports: [80, 443] | <ports>80</ports><ports>443</ports> |
"@version": 2 | attribute version="2" |
Block scalar | | element text with the line breaks preserved |
~ or null | empty element |
# comment | dropped (comments aren't data) |
Things that trip people up
- Unquoted @ keys. In YAML, @ can't start a plain scalar, so write attribute keys quoted:
"@id": 7. - yes/no booleans. This parser follows YAML 1.2, where only true/false are booleans;
country: NOstays the string NO. Older YAML 1.1 tools would have read it as false. - Anchors and aliases.
<<: *defaultsmerge keys aren't expanded here — the line is read as an ordinary key holding the text*defaults. Inline the values first. - Tabs in indentation. YAML forbids tabs for indentation; they're converted to two spaces before parsing, but mixed indentation can still shift keys to the wrong level.
YAML vs XML at a glance
| Property | YAML | XML |
|---|---|---|
| Specification | YAML 1.2.2 (2021) | XML 1.0 Fifth Edition (W3C, 2008) |
| File extension | .yaml / .yml | .xml |
| Media type | application/yaml (RFC 9512) | application/xml (RFC 7303) |
| Data types | string, int, float, bool, null, map, sequence (+ dates in many parsers) | text only (types come from a schema) |
| Comments | Yes # | Yes <!-- --> |
| Nesting | Unlimited (indentation) | Unlimited |
- YAML: YAML 1.2 is a superset of JSON; YAML 1.1 parsers (still common) also read yes/no/on/off as booleans — the “Norway problem”.
- XML: A document has exactly one root element; element names can't start with a digit, and only five entities (& < > " ') are predefined.