JSON to XML Converter
Convert JSON to well-formed XML: keys become elements, @-prefixed keys become attributes and arrays become repeated elements. Switch direction to turn XML back into JSON (or open the dedicated XML to JSON converter). Runs 100% in your browser.
JSON input
XML output
attr
root
How JSON maps to XML
| JSON | XML |
|---|---|
| {"title": "Guide"} | <title>Guide</title> |
| {"book": {"@id": "b1"}} | <book id="b1"/> |
| {"note": {"@lang": "en", "#text": "Hi"}} | <note lang="en">Hi</note> |
| {"tag": ["a", "b"]} | <tag>a</tag><tag>b</tag> |
| {"empty": null} | <empty/> |
- This mapping is lossy: comments and processing instructions are dropped, text is trimmed, and mixed text/child ordering is not preserved. Repeated siblings are grouped, so their original order relative to other names is lost.
- JSON names may be normalized to XML names. Empty arrays disappear, and null, empty text and empty elements cannot always be distinguished when converting back.
- XML has no data types: numbers and booleans become text in XML, and are detected again when converting back to JSON.
- A single repeated element can't be told apart from a single object, so one
<book>becomes an object and two become an array.