DEVELOPER TOOL

XML ↔ JSON Converter

Convert XML to JSON, and back, with attributes and arrays handled.

About this tool

Convert XML into JSON, or JSON back into XML. Element attributes become @attribute keys, repeated sibling elements become JSON arrays, and text content becomes a plain string or a #text key when an element has both attributes and text.

Parsing uses your browser's built-in XML parser, so nothing is uploaded — everything happens locally.

Frequently asked questions

How are XML attributes represented in JSON?
An attribute like id="1" becomes the key "@id": "1" on that element's JSON object, keeping attributes visually distinct from child elements.
How does this know when to make a JSON array?
Whenever an element has more than one child with the same tag name, those children are collected into a JSON array under that tag name — a single occurrence stays a plain object.
Is the conversion perfectly reversible?
For most everyday XML, yes — round-tripping XML → JSON → XML preserves structure, attributes, and text. Some XML-specific features (namespaces, processing instructions, mixed text/element content, comments) aren't fully preserved, since JSON has no equivalent concept.