NV ToolkitFormat · Validate · Convert

Converters

XML to YAML Converter

From angle brackets to clean indentation — XML parsed and re-expressed as readable YAML.

In short

Convert XML to YAML online: elements become keys, repeated tags become lists, attributes kept with @ prefix — clean YAML for configs. Free and instant.

By NaveenKumar T · Updated

Learn: JSON vs YAML: Which Format When?

  • Instant in-browser conversion
  • Validates input first
  • Repeated tags become YAML lists

Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →

Example

XML to YAML: input and output

A playlist: attributes on the root and on each repeated <track>, plus a <rating> element that has both an attribute and text content.

Input · XML
<playlist name="Focus mix" public="false">
  <track id="1"><title>Weightless</title><artist>Marconi Union</artist><seconds>485</seconds></track>
  <track id="2"><title>Clair de lune</title><artist>Debussy</artist><seconds>301</seconds></track>
  <rating stars="4">Calm, works well</rating>
</playlist>
Output · YAML
playlist:
  track:
    - title: Weightless
      artist: Marconi Union
      seconds: 485
      "@id": 1
    - title: Clair de lune
      artist: Debussy
      seconds: 301
      "@id": 2
  rating:
    "#text": "Calm, works well"
    "@stars": 4
  "@name": Focus mix
  "@public": false

The repeated <track> elements became a dash list; every attribute is an @-prefixed key wrapped in quotes because @ is a YAML indicator; the rating's text sits under "#text" next to "@stars": 4; and Calm, works well is quoted because of its comma while Focus mix and Marconi Union are not.

Learn more

How XML to YAML conversion works

The XML is parsed to a structured tree first: elements to keys, repeated elements to lists, attributes to @-prefixed keys, text content preserved. That tree is then serialized as YAML — dash lists for the repeated elements, two-space indentation for nesting, and quoting applied only where YAML would otherwise misread a value.

Validation happens before conversion, so broken markup is reported with its exact position instead of producing partial YAML.

When to convert XML to YAML

Typically a modernization step: an old service's XML configuration needs to become the YAML a new deployment system expects, or XML data needs to be reviewed by humans who find YAML dramatically easier to scan. Converting via a real parser preserves structure that regex-based hacks lose.

Help

Frequently asked questions

Everything you need to know about the XML to YAML.

01What happens if my XML has only one <track> instead of several?

A single occurrence of a repeatable element parses as one scalar or mapping rather than a one-item list — <tracks><track>A</track></tracks> becomes track: A, not track: [A] — because the parser only builds an array once an element actually repeats. If a consumer expects a list unconditionally, make sure the source XML repeats the element at least twice, or adjust the YAML afterward.

02Will the YAML round-trip back to the same XML?

Elements, lists, attributes (as @keys) and text all survive the round trip structurally. Byte-exact round-trips aren't guaranteed: comments, processing instructions, and original attribute order are XML-specific features without YAML equivalents.

03How do attributes and element text appear in the YAML?

Attributes keep the @ prefix from the parse step, and because @ is a reserved indicator in YAML the key is written in double quotes: "@id": 7. Text that shares an element with attributes is stored under "#text" (a bare # would start a comment). Attribute keys are listed after the element's children. Repeated elements become a dash list under the element name, values that look numeric are typed as numbers, and an element with no content becomes the empty string "".

04Can I go XML to YAML to XML and diff the two documents to check nothing changed?

You can, but expect noise in the diff even when the data matches: two-space indentation replaces your original formatting, an empty element round-trips as the empty string "" rather than a self-closing tag, and a source root element with a name other than root is renamed on the way back, since nothing records the original root's name for the return trip. Diff the parsed structures, not the raw text.

Keep working

Related tools

Learn the format

Related guides

All guides →