XML to YAML Converter

Convert XML into YAML that is easy to read and edit, for config files, Ansible, Kubernetes, and CI pipelines. Attributes and repeated elements are kept.

Updated
Runs in your browser. Your data is not uploaded.
Converts as you type for inputs up to 200 KB.

How to use the XML to YAML Converter

  1. Paste XML into XML input, or upload or drop an .xml file.
  2. Pick the Indent for the YAML.
  3. Press Convert, then copy the YAML or download converted.yaml.

How it works

The XML is parsed and checked first, then each element becomes a YAML mapping key:

  • Nested elements become nested mappings, indented under their parent.
  • Elements that repeat under the same parent become a list, written with - in front of each item.
  • Attributes become keys such as "@id". The @ sign is reserved in YAML, so these keys are quoted.
  • Text next to attributes or children goes under "#text".
  • Values that YAML would read as another type, such as yes, no, 1.0, or null, are quoted so they stay text.

Examples

Input:

<service name="web">
  <image>nginx:1.27</image>
  <port>80</port>
  <port>443</port>
  <debug>no</debug>
</service>

Output:

service:
  '@name': web
  image: nginx:1.27
  port:
    - '80'
    - '443'
  debug: 'no'

Limitations

  • Comments in the XML are not carried over.
  • All values are strings in the output, because XML has no types. Remove the quotes by hand if your tool expects a number or boolean.
  • The order of different sibling elements can't be kept, because a YAML mapping has no order.
  • Files are limited to 5 MB.

Frequently asked questions

Why are some values in quotes?

Without quotes, YAML would read 80 as a number and no as the boolean false. The quotes keep the original XML text.

Can I go from YAML back to XML?

Yes. The YAML to XML converter uses the same @ and #text keys.

Is YAML better than XML for configuration?

YAML is shorter and easier for people to edit, which is why Kubernetes, Docker Compose, and GitHub Actions use it. XML has stronger schema tools and is still common in Java, .NET, and enterprise systems.

Is my data uploaded?

No. The conversion runs in your browser.

Often used together with the XML to YAML Converter.