🔃 XML ↔ JSON Converter
Paste XML to get JSON, or JSON to get XML — attributes, repeated elements and text nodes handled, entirely in your browser.
Frequently Asked Questions
How are XML attributes represented in JSON?
Attributes become keys prefixed with @ — so <book id="1"> becomes {"@id": 1}. When an element has both attributes and text content, the text is stored under a "#text" key. The JSON → XML direction reads the same convention back, so conversions round-trip.
What happens with repeated elements?
Sibling elements with the same name are grouped into a JSON array — three <book> elements become "book": [...]. Going the other way, a JSON array produces one XML element per item with the same tag name.
How is the XML root element chosen when converting JSON to XML?
If the JSON is an object with exactly one top-level key, that key becomes the root element. Otherwise the output is wrapped in a <root> element. Keys that are not valid XML names have invalid characters replaced with underscores.
Are values like "42" and "true" converted to numbers and booleans?
With "Detect numbers & booleans" checked (the default), text that looks like a number or true/false becomes a typed JSON value; everything else stays a string. Turn it off to keep all XML text as strings — useful when IDs have leading zeros.
Are namespaces, comments and CDATA supported?
Prefixed names like soap:Envelope are kept as-is in JSON keys, and xmlns declarations appear as @xmlns attributes. CDATA content is treated as text. XML comments are dropped, since JSON has no comment syntax.
Is my data uploaded to a server?
No. The conversion runs entirely in your browser with JavaScript — your XML or JSON never leaves your device, so it is safe for API payloads and configuration files.