UTILS.
100% in-browser
🔁

XML to JSON Converter

Convert XML to JSON and back in your browser, preserving attributes, text nodes and repeated elements.

output

About this tool

XML to JSON Converter is a free, in-browser tool that converts between XML and JSON in both directions. Paste XML and press XML → JSON to get a structured JSON object; paste JSON and press JSON → XML to rebuild the markup. The conversion runs entirely on your device using the browser's native parser — nothing is uploaded and it keeps working offline.

Going from XML to JSON, each element becomes an object: attributes are stored under keys prefixed with @, text content lives under #text (or becomes the value directly when an element has no attributes or children), and repeated child elements collapse into an array. Going the other way, the same conventions are reversed — @keys become attributes, #text becomes element text, arrays expand back into repeated tags — and the output is indented and XML-escaped. If the input is not well-formed XML or valid JSON, the tool reports it rather than producing broken output.

Use it to inspect a SOAP or RSS payload as JSON, to feed legacy XML into a JSON-only API, or to hand-author XML by writing simpler JSON first. It complements a one-way JSON-to-XML generator and an XML pretty-printer by covering the missing XML → JSON direction with a real parse.

Frequently asked questions

How are XML attributes represented in the JSON?
Each attribute becomes a key prefixed with @ on the element's object — so <note id="1"> yields "@id": "1". When you convert JSON back to XML, any key starting with @ is written out as an attribute, which keeps round-trips faithful.
What happens to text inside an element?
If an element has only text, its value is that string directly. If it also has attributes or child elements, the text is stored under a #text key so nothing is lost. The reverse direction turns #text back into the element's text content.
How are repeated tags handled?
When an element contains several children with the same tag name, they are grouped into a JSON array under that name. Converting back, an array expands into one repeated element per item, so lists survive the round trip.
Does it validate my input, and is it private?
It parses with the browser's built-in DOMParser and reports malformed XML or invalid JSON instead of guessing. There is no schema or DTD validation. Everything runs locally in your browser — your data is never uploaded and no external libraries are loaded.

More tools