Skip to content
gohacks.dev
Web

JSON to XML Converter

Convert JSON to well-formed XML in your browser, with a root element of your choice, arrays as repeated elements and @-prefixed keys as attributes.

Free · No sign-up · Your inputs stay in your browser

Input

Convert JSON to XML

Output

XML

439 characters

Arrays repeat their parent's element name, which is how most XML APIs model lists. Keys that are not valid XML names are rewritten with underscores, and a #text key becomes the element's text.

Runs in this browser. Nothing you paste is sent to a server.

There is no single right mapping

JSON has arrays and typed values; XML has attributes, mixed content and repeated elements. Every converter picks a convention, and the one here is the common one used by Jackson's XmlMapper and by most SOAP bridges: an array of items under a key becomes several elements with that key's name. If the receiving system expects a wrapper element around lists, add it to the JSON first.

Escaping and names

The five characters XML reserves (&, <, > and both quotes) are escaped in text and attribute values. Element names may not start with a digit or with the letters xml, so keys like 2fa are prefixed with an underscore. The result is well-formed; checking it against an XSD needs the schema, which the XML formatter page explains.

Share

Frequently asked questions

How are JSON arrays represented in XML?
Each item becomes an element named after the array's key, so {"tag": ["a", "b"]} becomes <tag>a</tag><tag>b</tag>. A top-level array is wrapped in the root element with each item named item.
How do I make an XML attribute from JSON?
Prefix the key with @, as in {"user": {"@id": "42", "name": "Ada"}}, which gives <user id="42"><name>Ada</name></user>. Only scalar values can become attributes.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools