YAML to XML

Convert YAML to XML instantly in your browser.

Local Your input is processed locally in your browser. The first run loads the open-source js-yaml library from this site; your input is not sent anywhere. Found a problem? Report an issue

What YAML to XML does

YAML to XML reads YAML and writes it as XML. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.

YAML to XML examples

The built-in sample

Input

name: Ada
tags:
  - math
  - code
address:
  city: London

Output

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <name>Ada</name>
  <tags>math</tags>
  <tags>code</tags>
  <address>
    <city>London</city>
  </address>
</root>

This is the input that the Load sample button fills in.

Several top-level keys, an alias and a null

Input

version: 1.10
enabled: yes
released: 2024-01-05
base: &b
  retries: 3
prod: *b
host: ~
# trailing comment

Output

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <version>1.1</version>
  <enabled>yes</enabled>
  <released>2024-01-05T00:00:00.000Z</released>
  <base>
    <retries>3</retries>
  </base>
  <prod>
    <retries>3</retries>
  </prod>
  <host/>
</root>

Because the document has more than one top-level key, everything is wrapped in a root element. The aliased mapping is written out twice, and the null value becomes an empty host element.

Each output was produced by running this tool on the input above it.

How it works

Reading YAML. The input is parsed with js-yaml. Values keep the types YAML assigns them (numbers, booleans, null and timestamps), anchors and aliases are expanded into full copies, and comments are dropped.

Writing XML. Each key becomes an element and each array item repeats its element. Keys starting with @ become attributes and #text becomes text content. Keys that are not valid XML names are written as item. A single top-level key becomes the root element; anything else, including a top-level array, is wrapped in one root element so the output is always well-formed. Special characters are escaped.

Details and limits

  • Values are carried across without losing anything in ordinary data; the points above list the cases the two formats handle differently.
  • YAML keys that are not valid XML names, for example keys with spaces or keys that start with a digit, are written as item.
  • A list at the top level becomes item elements inside root.
  • Types are lost: the number 3 and the string "3" both become the text 3.
  • Input that is not valid YAML stops the tool, and the status line shows where the problem is. The YAML Validator page lists the usual causes.

Questions

Is my data uploaded when I use YAML to XML?

No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.

What does YAML to XML do?

YAML to XML reads YAML and writes it as XML. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.

Are there any limits I should know about?

YAML keys that are not valid XML names, for example keys with spaces or keys that start with a digit, are written as item. A list at the top level becomes item elements inside root.

Is there a size limit?

There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.

Does it work on phones, and is it free?

Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.