XML to YAML Converter
Rewrite verbose XML as concise, indentation-based YAML — the same data, minus the closing tags, ready for a config file or a quick read.
Trading angle brackets for indentation
YAML and XML can hold the same hierarchical data, but they express it very differently. XML repeats every name twice — once to open a tag, once to close it. YAML drops the closing tags entirely and uses indentation to show nesting, which makes it dramatically shorter and, for many people, easier to scan. This tool performs that translation.
The pipeline is two-stage. First xml2js parses your XML into a JavaScript object. Then js-yaml's dump function serialises that object into YAML. Because it's a clean parse-then-serialise round trip, the structure carries over faithfully — keys, nesting and values all land where you'd expect.
Both steps run in the browser. Infrastructure configs and service definitions you'd rather not paste into a remote tool stay entirely on your own machine.
Converting XML into YAML
- 1
Paste your XML
Add the XML to the input pane, or upload an .xml file. The sample button loads a small document to try.
- 2
Read the YAML
The indentation-based YAML appears in the output pane as you type — no closing tags, just clean nesting.
- 3
Verify the shape
Check that the indentation reflects the structure you intended. Invalid XML is reported before conversion.
- 4
Copy or download
Copy the YAML or save it as a .yaml file for your config directory or pipeline.
Why reach for YAML
Far less boilerplate
Dropping closing tags and attribute syntax typically cuts the character count substantially versus the source XML.
Config-file friendly
YAML is the format of choice for CI, Docker Compose, Kubernetes and Ansible — this gets your data there in one step.
Easier to eyeball
Indentation maps directly to structure, so the nesting is obvious without hunting for matching tags.
Stays on your machine
xml2js and js-yaml both run client-side, so secrets in your config never get uploaded.
Side by side
The XML source on the left, the YAML js-yaml emits on the right.
<server>
<host>api.example.com</host>
<port>8080</port>
<tls>true</tls>
</server>server:
host: api.example.com
port: '8080'
tls: 'true'What changes when XML becomes YAML
The most visible difference is verbosity: <name>Ada</name> collapses to name: Ada. Attributes that xml2js stores under a $ key surface in the YAML as a nested $ mapping, and text alongside attributes appears under _. Since YAML is whitespace-sensitive, the indentation js-yaml emits is the structure — change it carelessly and you change the meaning, so treat the output as you would any YAML file.
A note on types and comments
- XML values arrive as strings, so YAML scalars are strings too — js-yaml won't invent numbers or booleans that weren't typed in the source.
- XML comments are not carried into the YAML; only data crosses over.
- If a value happens to look like a YAML keyword (such as
yesornull), check how your YAML loader interprets it on the other side.
Frequently asked questions
XML has no types, so every value comes through as a string. js-yaml quotes scalars like '8080' and 'true' to make clear they're strings, not a number or a real boolean. Convert them in your loader if you need actual types.
Attributes are preserved. xml2js stores them under a $ key while parsing, so in the YAML you'll see a nested $ mapping holding the attribute names and values for that element.
No. xml2js parses the XML and js-yaml produces the YAML entirely in your browser. You can run it offline, which keeps infrastructure configs and secrets private.
No. The converter works on the parsed data structure, and XML comments aren't part of that data, so they're dropped. Only elements, attributes and text are translated.
Not directly with this tool. You could convert the YAML to JSON and then JSON to XML, but a perfect round trip isn't guaranteed because comments and exact formatting aren't preserved.
The XML couldn't be parsed — usually an unclosed tag, mismatched nesting, multiple roots, or an unescaped special character. Fix the structural issue and the YAML will generate.
Need another tool?
Browse the full toolbox or dig into the blog for the engineering behind it.