YAML / XML Converter

Convert YAML or JSON to XML and XML back to YAML or JSON in your browser. Attributes are kept as @_ keys and repeated tags become lists. Invalid XML is reported with its line and column. Choose the left pane format, indent size and pretty printing, then copy or download the result.

About this tool

What does this converter do?

XML represents data as nested tags with attributes, while YAML and JSON use keys, lists and values. This tool maps one to the other so you can, for example, turn an XML API response or config file into readable YAML or JSON, or build XML from a YAML document. The left pane holds YAML or JSON and the right pane holds XML.

How to use

  1. Under Left pane, choose YAML or JSON.
  2. Paste data into the left editor or the XML editor on the right, or drop a file onto either one.
  3. Click To XML to convert left to right, or To YAML / To JSON to convert right to left.
  4. Adjust Indent size and Pretty print (XML / JSON) if needed, and use the Copy to clipboard or Download button on the result.

Features

  • Both directions: YAML/JSON to XML and XML to YAML/JSON
  • Attributes preserved: <title lang="en"> becomes @_lang: en, and element text with attributes is stored under #text, so data can be converted back
  • Repeated elements such as several <tag> siblings become a list, and a list becomes repeated elements
  • Leading zeros kept: values like 0123 stay strings instead of turning into numbers
  • Validation: malformed XML is rejected with the line and column of the problem
  • Pretty print toggle for XML and JSON output (YAML is always indented)
  • Empty values are written as self-closing tags such as <empty/>

Example

XML input:

To YAML result:

FAQ

Is my data sent anywhere?

No. Parsing and conversion run in your browser (js-yaml and fast-xml-parser); nothing is uploaded.

Why does To XML say the top level must be a mapping?

XML needs named elements, so the YAML or JSON must start with key: value pairs. Wrap a top-level list or single value in a key first, for example items: [...].

Why do I get "cannot be represented as well-formed XML"?

Every key becomes a tag name, and XML tag names cannot contain spaces or start with a digit. Rename keys like first name or 1st before converting.

What happens to XML comments and the <?xml ...?> declaration?

Comments are dropped. The declaration is kept as a ?xml key (with @_version and so on), and converting that data back with To XML writes the declaration again.