DEV

XML to JSON and JSON to XML Converter

Paste XML or JSON on the left, choose a direction, and get the converted result on the right. Everything runs in your browser.

INPUT
OUTPUT

          

How the conversion works

XML elements become JSON keys. Attributes are written as keys that start with @, and mixed text is stored under #text. Elements that repeat under the same parent turn into arrays. Converting back reverses these rules, so a round trip gives you equivalent XML.

JSON has no native attributes or element order, so XML to JSON to XML may not keep every detail such as comments, processing instructions or CDATA sections. Those are dropped on purpose.

Frequently asked

How are XML attributes represented in JSON?

Attributes become keys prefixed with @, for example <item id="1"> becomes {"@id": "1"}. Text that sits alongside attributes or child elements is stored under the key #text.

What happens to repeated elements?

Sibling elements with the same name are grouped into a JSON array, so a list of <item> tags becomes "item": [ ... ]. A single element stays a plain value.

Is my data uploaded anywhere?

No. Conversion runs entirely in your browser using its built-in XML parser, so nothing you paste leaves your device.

Why does JSON to XML fail on my input?

XML needs one root element and element names that start with a letter or underscore. Keys that break those rules are reported in the status message. Wrap multiple top-level keys in a single parent key, or let the tool add a <root> wrapper.