JSON to XML converter
The result appears here.
Convert
Your document never leaves the browser.
JSON to XML with @ keys as attributes and null as xsi:nil — in your browser.
Paste JSON and get well-formed XML, written the way XML to JSON reads it back — so the round trip keeps what XML can hold.
The JSON
{
"order": {
"@id": "7",
"item": ["pen", "ink"]
}
}The XML it gives, at the default settings
<?xml version="1.0" encoding="UTF-8"?>
<order id="7">
<item>pen</item>
<item>ink</item>
</order>Mapping
An object with exactly one key, whose value is not an array, names the root element. Anything else is wrapped in a root element you name under Root element (root by default), and the result says it was added.
Mapping
"@name" keys with a plain value become attributes; "#text" becomes text; every other key becomes a child element, in key order.
Mapping
An array becomes one repeated element per item. An array directly inside an array has no name to repeat, so its items are written as <item>, with a notice.
Mapping
Numbers are written with their exact digits; booleans as true and false.
Mapping
The output starts with an XML declaration and is indented at the Settings ⚙ width — 2 spaces when that is a tab.
With Write null as xsi:nil on (the default), null becomes <a xsi:nil="true"/>, with the namespace declared once on the root, so it reads back as null. Off, it is an empty element, and the notice says those nulls come back as "".
A key that is not a legal XML name — first name, 2fa, an empty key — is encoded in the _x0020_ style XmlConvert uses, and decoded again on the way back. The result counts them. Text and attribute values are escaped, including line breaks and tabs in attributes that XML would otherwise normalise away.
A key with a space in it, and a null
{
"user": {
"first name": "Ada",
"email": null
}
}The XML it gives, at the default settings
<?xml version="1.0" encoding="UTF-8"?>
<user xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<first_x0020_name>Ada</first_x0020_name>
<email xsi:nil="true"/>
</user>An empty array writes nothing, so its key disappears; a repeated key becomes repeated elements and reads back as an array. Types do not survive the round trip unless Detect numbers and booleans is on when reading back. Each of these is noted when it happens. A string holding a character XML 1.0 cannot represent at all, such as U+0000, is refused with its location.
A string holding U+0000
{
"note": "a\u0000b"
}✕ Line 2, column 11: XML cannot hold U+0000 at all.
The conversion runs in your browser, in the same engine the editor uses. The document is never uploaded, never logged and never leaves your machine — there is no server to send it to. Once the page has loaded it keeps working with the connection off.
Going the other way?
Prefix the key with @: {"book": {"@id": "b1", "title": "Dune"}} writes <book id="b1"><title>Dune</title></book>.
Yes, when one has to be added. A document that already has a single root key uses that key.
Yes, and they are shared with the editor’s JSON to XML panel.