XML ↔ JSON
XML ↔ JSON — runs in your browser. Inputs are not stored.
XML ↔ JSON
Enter values, then press Calculate.
Processed with the browser DOMParser. Complex namespaces are simplified.
How to use
- Under Direction, choose XML → JSON or JSON → XML.
- Paste an XML document or a JSON object in Input.
- Press Convert, check the result, and Copy. On error, read the hint message.
- Several children with the same name are grouped into a JSON array. Attributes go in an @attributes object.
- Reset clears the fields. Complex namespaces can be simplified or break.
Key concepts
XML JSON conversion is for changing format in API samples, config files, and legacy integrations. XML is read with the browser DOMParser into objects of elements, text, and attributes; JSON is serialized as a simple tag tree. It is client DOM, not a server parser. It is a converter that uses the browser DOMParser to view a legacy XML API sample as JSON, or to turn JSON config into a simple XML tree. It is a client converter for previewing how attributes and repeated elements become objects and arrays when you move between config XML and a JSON API. It is for checking samples, so namespaces and DTDs on production data can be lost. After conversion, check keys and array shape once more.
If the JSON root has several keys, they are wrapped in a root element when sent to XML. Documents with many xmlns namespaces, entities, or CDATA can lose data. The purpose differs from a formatter (indent-only) tool. Processing is local. Heavy namespaces, DTDs, and entities are lost. The purpose differs from a formatter (indent-only) tool. Documents with strict schemas and namespaces can lose data, so it is closer to sample checking than production-data conversion.
Example
XML → JSON of <root><item>1</item><item>2</item></root> groups item as an array. <user id="1"> with an attribute goes into @attributes. Conversely, converting {"a":1,"b":2} JSON → XML creates tags wrapped in root.
Related: JSON formatter · XML formatter
Frequently asked questions
What happens to XML attributes in JSON?
They are stored in an @attributes object. Attributes are separated under @attributes so names do not collide with JSON keys. Attributes are collected under @attributes.
Are XML namespaces kept as they are?
They are simplified, and complex NS can break. A long xmlns may leave only the tag’s local name.
Do several identical tags become a JSON array?
Several children with the same name are grouped into an array. Repeated elements are arrays and a single one is an object, so the structure can be asymmetric. The type can differ when there is one element versus several.
What XML do you get if the JSON root has several keys?
They are wrapped in a root element. Several root keys are wrapped as root on the XML side.
Is XML JSON conversion parsed on a server?
No. Only the browser DOMParser is used. Parsing happens only in this tab.
What message appears for invalid XML?
If parsing fails, a hint is shown instead of a result. Try closing tags. If it still fails, check the XML declaration and closing tags first, then try again.
Last reviewed: 2026-09-04