YAML to XML Converter
Convert YAML documents to well-formed XML with configurable root element and indentation.
or drop a file here
How YAML-to-XML conversion works
This converter parses your YAML using the same js-yaml parser used elsewhere on the site, then serializes the resulting JavaScript object tree to XML. Object keys become element names, arrays get wrapped in their parent element with <item> children, and all values are properly XML-escaped. Key characters illegal in XML tag names are replaced with underscores.
For other YAML conversions, see YAML to JSON or YAML to TOML. To go the other direction, use XML to JSON.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing XML for a legacy system from a YAML source of truth.
- Converting configuration for a tool that only accepts XML.
- Generating an XML fixture from a readable YAML definition.
- Migrating a manifest into an XML-based pipeline.
- Comparing a YAML structure against an XML schema's expectations.
Frequently Asked Questions
- Why did my key get renamed?
- Because XML element names are far stricter than YAML keys. Anything outside letters, digits, `_`, `-`, `.` and `:` becomes an underscore, and a name that starts with a digit gets one prefixed — `2fa: true` cannot be `<2fa>`, so it becomes `<_2fa>`.
- How does a YAML list become XML?
- Each item is repeated as a sibling element with the same tag, because XML has no array type — `ports: [80, 443]` becomes two `<ports>` elements. Round-tripping back cannot then tell a one-item list from a plain value.
- Which characters are escaped?
- The five predefined entities: `&` → `&`, `<` → `<`, `>` → `>`, `"` → `"`, `'` → `'`. The ampersand must be escaped first or you double-encode — `<` would otherwise become `&lt;`.
- Are YAML anchors preserved?
- No — they are resolved. `<<: *defaults` expands into a full copy of the referenced block in every place it is used, so shared structure that appeared once in YAML appears repeatedly in the XML. That is inherent: XML has no anchor concept.
- Why does everything need a root element?
- Because an XML document must have exactly one. YAML happily starts with a list or a scalar, so a wrapper tag is added; you can name it. Multi-document YAML (`---` separators) has no XML equivalent at all and only the first document converts.
- How are YAML lists represented in XML?
- As repeated sibling elements, since XML has no array type — a list of three becomes three elements with the same name. That is why converting back requires knowing which repeated elements were a list and which were coincidence.
Common errors and gotchas
- Producing element names from keys that are not valid XML names, such as ones starting with a digit.
- Losing the distinction between an attribute and a child element, which YAML does not express.
- Converting a list without a wrapping element, which produces repeated siblings a schema may reject.
- Assuming types survive. XML text content is text, whatever YAML inferred.
- Overlooking characters that must be escaped in XML, which YAML carries literally.
Related Converters tools
JSON to YAML
Convert JSON into clean, readable YAML instantly.
YAML to JSON
Convert YAML configuration into valid JSON.
JSON to XML
Convert JSON structures into nested XML markup.
HWB to HEX Converter
Convert an HWB color to HEX.
JSON to SQL
Turn a JSON array of objects into SQL INSERT statements.
CSV to XML
Convert CSV rows into structured XML records.
XML to CSV
Flatten repeated XML records into CSV rows.
INI to JSON
Parse INI config sections and keys into JSON.