What is JSON ↔ XML conversion?
JSON and XML are both text-based formats for representing structured data, but they use very different syntax. JSON uses braces, brackets, and colons; XML uses angle-bracket tags with attributes and nesting. Many APIs and systems that used XML in the early 2000s have shifted to JSON, but legacy systems, SOAP services, and config files often still use XML. This tool converts between the two formats using pure JavaScript — no server, no library.
How to use this tool
- 1 Choose "JSON → XML" or "XML → JSON" using the tab buttons.
- 2 Paste your data in the Input panel — the conversion runs live as you type.
- 3 Use the swap button (↔) to flip the output back into the input and switch modes for round-trip conversion.
Frequently asked questions
Are XML attributes preserved in JSON?
Yes. XML attributes are included in the JSON output as keys prefixed with @ (e.g. @id, @class) following a common convention. This is lossless for most documents.
What happens with arrays in JSON?
JSON arrays become repeated XML elements with the same tag name. For example [{"name":"Alice"},{"name":"Bob"}] under an "item" key becomes two <item><name>…</name></item> elements.
What is the root element in the XML output?
If the JSON object has a single top-level key, that key becomes the root element. Otherwise a <root> wrapper is added automatically.
Does it handle nested structures?
Yes — nested objects become nested XML elements recursively. Arrays become repeated sibling elements.
Is my data sent to a server?
No. Conversion runs entirely in your browser using native DOMParser for XML parsing and a hand-rolled serialiser for JSON-to-XML.