xmltoolskit.org
XML utilities, in the browser
Say hi →

YAML to XML

updated 20 August 2026 · YAML 1.2 · js-yaml

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 → xml
Drop a .yaml file here, or
ready

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

  1. Paste YAML into the left pane, or drop a .yaml file.
  2. Name the root element — XML needs exactly one, even when your YAML starts with a sequence.
  3. Pick how sequences are written: a wrapper element containing <item> children, or the parent tag repeated once per entry.
  4. 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

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

Privacy

100% client-side. The YAML is parsed by a script in the page. See the privacy policy.