How to Convert XML to YAML for Configuration Files
Last updated: 2026-04-15
XML was the default configuration format for Java, .NET, and enterprise systems for two decades. Modern frameworks have largely moved to YAML: Spring Boot accepts application.yml alongside application.xml, and Kubernetes uses YAML exclusively. If you are migrating a project or consolidating config formats, converting XML to YAML is a common first step.
Step-by-Step: Convert XML to YAML
- Open Convertee and select XML as the source and YAML as the target.
- Paste your XML configuration or drop a
.xmlfile. - Adjust YAML options: indent width, whether to quote strings, and how to handle XML attributes.
- Click Convert (Cmd+Enter).
- Copy or download the YAML output.
The conversion is entirely client-side. Your XML stays in the browser.
Before / After Example
Input XML (Spring-style):
<configuration>
<server>
<port>8080</port>
<host>0.0.0.0</host>
</server>
<database>
<url>jdbc:postgresql://localhost/mydb</url>
<pool-size>5</pool-size>
</database>
</configuration>Output YAML:
configuration:
server:
port: 8080
host: "0.0.0.0"
database:
url: "jdbc:postgresql://localhost/mydb"
pool-size: 5Understanding the Mapping
XML elements map to YAML keys. Nested elements become nested mappings. Text content becomes the value. XML attributes are handled by prefixing attribute names with @ (a common convention also used by libraries like Jackson and xmldom).
The XML specification (W3C XML 1.0) allows mixed content, namespaces, and processing instructions that have no direct YAML equivalent. Convertee handles the common cases; for complex XML with mixed content, manual review of the output is recommended.
Common Migration Scenarios
- Spring Boot. Converting
application.xmltoapplication.yml. YAML is more readable for deeply nested Spring properties. - CI/CD pipelines. Legacy Jenkins XML configurations migrated to YAML-based alternatives like GitHub Actions or GitLab CI.
- Maven to Gradle. While not a direct format swap, extracting dependency data from
pom.xmlas YAML helps when building Gradle scripts. - Docker Compose. Legacy Docker tooling used XML configuration. Docker Compose standardized on YAML, making migration a format conversion plus structural adjustment.
Gotchas
- Attribute vs. element ambiguity. XML distinguishes
<port value="8080"/>from<port>8080</port>. YAML has no equivalent to attributes, so Convertee uses the@prefix convention. - Repeated element names. XML allows multiple elements with the same name (
<item>siblings). These become a YAML array automatically. - CDATA sections.
<![CDATA[...]]>blocks are unwrapped and the raw text content is used as the YAML value.
Frequently Asked Questions
- How are XML attributes represented in YAML?
- XML attributes are prefixed with @ in the YAML output (e.g., <server port='8080'> becomes server: { '@port': 8080 }). This is a widely used convention in XML-to-JSON/YAML converters.
- Does this work with Spring Boot configuration files?
- Yes. Convertee handles standard Spring XML configuration and produces YAML that follows Spring Boot's application.yml conventions. Review the output for Spring-specific property mappings that may need manual adjustment.
- What happens with XML namespaces?
- Namespace prefixes are preserved in the YAML keys (e.g., xs:element becomes a key named 'xs:element'). For most configuration file migrations, namespaces are not present and this is not a concern.