XML to YAML
Convert XML documents into readable YAML.
XML to YAML Converter Online
The XML to YAML converter rewrites verbose XML as clean, indentation-based YAML. It is ideal when you migrate configuration from XML-based tools to YAML-based ones — Kubernetes manifests, GitHub Actions, Ansible, Docker Compose — or when you simply want a document that is easier for humans to read and review.
How the structure maps
Each element becomes a key and its children become nested mappings. Elements that repeat, such as several <book> entries in a catalog, turn into a YAML sequence. Attributes are kept as prefixed keys so no information is lost, and the text of an element that also carries attributes is stored under #text. Empty elements become null.
Options
- Attribute prefix –
@(quoted in YAML because @ is a reserved indicator),_, or-. - Indentation – 2 or 4 spaces per level.
- Detect numbers & booleans – writes
44.95andtrueas native YAML scalars instead of strings. - Remove namespace prefixes –
dc:creatorbecomescreator, and namespace declarations are dropped.
Safe quoting
YAML has surprising implicit types: no can become false and 2000-10-01 a date object. The converter quotes such strings, so the YAML means exactly what the XML said when it is loaded again. Long text values are never wrapped, which keeps diffs readable.
What is not carried over
Comments, processing instructions, and the XML declaration have no equivalent in the data model and are skipped. The order of keys follows the order of elements in the source, so the YAML reads top to bottom just like the original document.
When XML to YAML is useful
- Porting Maven or Spring XML configuration to YAML property files.
- Making large API responses easier to skim in code review.
- Preparing fixture data for tools that only accept YAML.
Related tools
Check the result with the YAML Validator, go back with YAML to XML, or produce JSON instead using XML to JSON. The YAML Converter handles further conversions.
Frequently Asked Questions
Why are some keys in quotes?
YAML reserves @ at the start of a plain scalar, so attribute keys like @id have to be quoted. Choose the _ or - attribute prefix if you prefer unquoted keys such as _id.
Is the YAML safe for older parsers?
Yes. Strings that YAML 1.1 parsers would misread — yes, no, on, off, and date-like values such as 2000-10-01 — are quoted, so PyYAML and go-yaml read them back as the same strings.
How are repeated elements shown?
As a YAML sequence: each repeated element becomes a list item introduced by a dash, with its attributes and child elements as keys underneath.