Skip to main content

XML to YAML Converter

Convert XML to YAML. Element names become map keys, attributes get a configurable prefix (or can be dropped entirely), text content gets a configurable key name, and repeated sibling elements become a YAML sequence automatically — with an option to force every element into a sequence so the shape never depends on how many times it repeats. Runs entirely in your browser.

Input

Drop a file or browse
One file · text
Or

Options

The key used for an element's own text when it also has attributes or child elements.

Wrap every child element in a sequence, even ones that appear only once, so the shape never depends on how many times an element repeats in a given document.

Output

YAML output
 
Was this helpful?

Guides

Paste XML, get YAML. This free online XML to YAML converter turns an app config, an API response or any other XML document into clean, human-readable YAML — the format most modern config files and CI pipelines actually use. Conversion happens as you type, with no upload and no sign-up.

How to use it

  1. Paste your XML into the input box, or drop an .xml file onto the uploader.
  2. Toggle Preserve XML attributes on or off. When on, choose an attribute prefix (@, _, or none) to control how attributes appear as YAML keys.
  3. Pick a text content key (#text, _text, or text) — used when an element has attributes or child elements alongside its own text.
  4. Toggle Strip namespace prefixes, Trim whitespace in text content, and Always represent child elements as arrays to match the shape your downstream code expects.
  5. Pick a 2- or 4-space indent and copy or download the result as converted.yaml.

The output updates automatically as you type.

How does XML map onto YAML?

Every element name becomes a map key. An element with no attributes and no child elements — just text, like <founded>1995</founded> — collapses to a plain YAML scalar. An element with attributes and/or children becomes a nested map: attributes become sibling keys carrying your chosen prefix (@id, _id, or plain id), child elements become nested keys, and any of the element's own text is stored under your chosen text key (default #text) alongside them. Sibling elements that share the same tag name automatically become a YAML sequence, in document order — a <department> that appears three times under <departments> becomes a department: list of three items.

Why does "always represent child elements as arrays" matter?

Without it, whether a given tag ends up as a scalar/map or a sequence depends entirely on how many times it happens to repeat in this particular document — a <book> catalog with one book gives you a map, but the same catalog with two books gives you a sequence, and code that reads the first book unconditionally breaks the moment a second one shows up. Turning this on wraps every child element in a sequence unconditionally, even a single occurrence, so the shape is predictable regardless of how many times an element actually repeats.

What does "Strip namespace prefixes" do?

XML namespaces write element and attribute names as ns:tag. With this on, the ns: prefix is dropped from tag and attribute names in the YAML output (ns:book becomes book) — except on the xmlns/xmlns:* declaration attributes themselves, which are left as-is since stripping them would lose which namespace they declare.

Are values typed as numbers or booleans?

No — every attribute and text value is kept as a string, exactly as written in the XML. XML has no native type system beyond the schema you bring to it, so guessing at numbers/booleans risks mangling values like IDs, version strings or ZIP codes that happen to look numeric. Because of this, the YAML output quotes strings like "true" or "1995" when needed — that's the YAML library correctly preserving the string type on re-parse, not a formatting quirk.

What if my XML is malformed?

The converter parses XML well-formedness — matching tags, a single root element, properly quoted attributes — and reports a clear error naming the specific problem instead of guessing at broken markup or silently producing garbage YAML.

Is my data private?

Completely. Parsing runs entirely in your browser using a self-contained XML parser — your data is never sent to a server, logged, or stored.

What's the inverse of this tool, or a different XML target?

The YAML to XML Converter does the reverse conversion. For a plain data-structure export instead, try the XML to JSON Converter; for a repeating-record export, try the XML to CSV Converter.

xmlyamlconverterdatadeveloper

Use it from code

From 3 credits per call

REST API

curl -X POST https://api.iotools.cloud/v1/tool/xml-to-yaml-converter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "xmlSource": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<company>…",
    "includeAttributes": "true",
    "attributePrefix": "@",
    "textKey": "#text",
    "stripNamespaces": "",
    "trimText": "true",
    "forceArrays": "",
    "indent": "2"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `xml-to-yaml-converter` tool (XML to YAML Converter) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.