Convert XML to YAML

Turn an XML document into readable YAML.

YAML

About this converter

Usually part of moving an old configuration into a modern toolchain — the sort of XML that has been in a project since before YAML existed, needed now in the format everything else uses.

Attributes keep an @_ prefix and text alongside them sits under #text, for the same reason as in JSON: YAML has one kind of key and XML has two, so without a mark the two collide and one is lost.

The result is considerably shorter than the XML, which is most of the reason for doing it. A closing tag on every line is a lot of characters that indentation conveys for free.

Frequently asked questions

Can I get rid of the @_ prefixes?

Not automatically, because dropping them can lose data — an element with both an id attribute and an id child would end up with one of them overwriting the other. If you know your document has no such collision, a find and replace on the result is safe.

Why is a single element not a list?

Because XML cannot tell you it should be. One and a list of one are written identically, and only a schema knows which was meant. Check for the single-value case if your code expects a list.

Does what I paste get sent anywhere?

No. The conversion runs in your browser, on your own machine — which is why the result appears as you type. Nothing is uploaded and nothing is logged. That matters for this kind of tool in particular: config files and API responses are exactly the things that carry keys, hostnames and customer data.

Related tools