XML to YAML Converter
Re-express a verbose XML document as indented YAML, which is often the quickest way to understand its structure.
Your data stays on your device
Input — XML
- characters
- 0
- lines
- 0
- size
- 0 B
Output — YAML
- characters
- 0
- lines
- 0
- size
- 0 B
Options
Comma separated. Keeps the shape stable when an element sometimes appears once.
About this tool
XML markup obscures shape. Closing tags, attribute quoting and namespace prefixes take up most of the visual space, and the actual hierarchy is hard to see. YAML shows the same tree with indentation and almost no punctuation.
The document is parsed with the same options as the XML to JSON tool — attribute prefix, text node key, array handling — and then written as YAML rather than JSON, so both tools agree on how the mapping is done.
How to use this tool
- Paste XML or upload a .xml file.
- Adjust the attribute prefix and text node key if the defaults clash with your element names.
- Press Convert to get YAML.
- Copy the result or download it as a .yaml file.
Key features
- Attributes mapped to prefixed keys
- Repeated elements collapsed into YAML sequences
- Configurable text node key for mixed content
- Configurable indentation width
- Values quoted only where YAML would otherwise change their type
- Optional stripping of namespace prefixes
Example
Input — XML
<host name="db-1"><port>5432</port></host>Output — YAML
host:
"@name": db-1
port: "5432"Good to know
- XML comments, DOCTYPE declarations and processing instructions are dropped.
- A single occurrence of an element cannot be distinguished from a one-item list without a schema.
- All values arrive as strings unless numeric coercion is enabled, which is off by default to avoid corrupting identifiers.
Frequently asked questions
Why do keys start with @ in the output?
That prefix marks values that were XML attributes rather than child elements. You can change or remove the prefix in the options.
Is the conversion reversible?
Structurally yes, if you keep the attribute prefix and text key conventions. Comments and formatting will not come back.
What about elements that appear once?
They become a single mapping rather than a sequence, unless you force arrays for that element name in the options.
Does it handle large feeds?
Documents in the low megabytes convert comfortably in the browser. Very large feeds are better handled by a streaming parser in a script.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.