YAML to XML
Turn a YAML document into XML: mappings become nested elements, sequences become a wrapper with repeated items (or a repeated parent tag), and scalars become text nodes or attributes — your choice.
YAML to XML
YAML is parsed with js-yaml (YAML 1.2 core schema), then the resulting value tree is serialised as XML. Anchors and aliases are resolved by the parser, multi-document files use the first document, and dates come out in ISO-8601 form.
How to use it
- Paste YAML into the left pane, or drop a
.yamlfile. - Name the root element — XML needs exactly one, even when your YAML starts with a sequence.
- Pick how sequences are written: a wrapper element containing
<item>children, or the parent tag repeated once per entry. - Copy the XML, or Download .xml.
Why sequences need a decision
YAML sequences have no direct XML equivalent. Wrapper + items keeps the list visible as a container — <tags><item>a</item><item>b</item></tags> — which round-trips cleanly and is easy to walk with XPath.
Repeat parent tag emits <tags>a</tags><tags>b</tags>, with no wrapper at all. That is the shape XSD sequences with maxOccurs="unbounded" describe, so it is usually the right choice when the XML has to validate against someone else's schema.
Types do not survive, and that is fine
XML text nodes are strings. A YAML integer, boolean, or null becomes text — 8080, true, and an empty element respectively — and the consumer decides how to read them. If types matter downstream, pair the output with an XSD; the schema validator will then check them for you.
What the parser handles
- Anchors and aliases (
&name/*name) are expanded before conversion. - Block and flow styles, multi-line scalars, and quoted keys all parse normally.
- Multi-document streams (
---separators) convert the first document. - Keys that are not valid XML names are sanitised: disallowed characters become hyphens, a leading digit gets an underscore.
FAQ
What if my YAML top level is a list?
XML requires a single root, so the list is written inside the root element you name. With wrapper + items you get <root><item>…</item></root>.
Are comments preserved?
No. YAML comments are discarded by the parser, and XML has nowhere to put them that would round-trip. Keep the YAML file as the source of truth.
Which YAML version is supported?
js-yaml 4 implements YAML 1.2 with the core schema. That means yes/no are strings rather than booleans — a deliberate YAML 1.2 change from 1.1.
How do I go the other way?
Use XML to YAML. Round-tripping is not byte-exact — attributes, comments, and item wrappers cannot all survive both directions — but the data comes back intact.
Is my file uploaded?
No. js-yaml runs in your browser and the conversion never touches a server.
Related tools
- XML to YAML — the other direction
- JSON to XML — same idea from JSON
- XML Formatter — re-indent or minify the result
- XML Sort — put the generated elements in a predictable order
- XSD to sample XML — generate an instance from a schema instead
Privacy
100% client-side. The YAML is parsed by a script in the page. See the privacy policy.