TXT · Text & Data tools

JSON to XML Converter

Input · JSON
Output · XML
0 Bin0 Bout0lines in0keysEmptyJSON
Go to the full Data Format Converter

JSON to XML

Convert a JSON object or array into XML elements. Paste JSON on the left; the XML output builds on the right as you type.

{ "order": { "@_id": "1042", "status": "shipped", "items": ["pen", "notebook"] } }

becomes

<?xml version="1.0" encoding="UTF-8"?>
<order id="1042">
  <status>shipped</status>
  <items>pen</items>
  <items>notebook</items>
</order>

order is the single top-level key, so it becomes the root element rather than sitting inside a generic wrapper. @_id becomes an id attribute on order. The items array becomes two sibling <items> elements, since XML has no native array type: repetition is the only way to represent one. The <?xml version="1.0"?> line comes from the XML declaration checkbox, on by default; turn it off if your destination doesn’t want a prolog.

Attributes vs. child elements

XML distinguishes attributes from child elements; JSON has only keys. This converter reads any key starting with @_ as an attribute and everything else as a child element or text. If your source JSON doesn’t use that convention, every key becomes a child element, which is usually still valid XML, just more verbose than attribute-heavy documents typically are.

Multiple top-level keys

When the JSON value has more than one top-level key, there’s no single obvious root element, so the converter uses the Root name field (default root) as the wrapper and puts every key underneath it as a child element. Set Root name to match what your XML schema or consumer expects.

Invalid element names

JSON keys can contain spaces, start with digits, or use punctuation that XML element names can’t. "1st place" becomes n1st_place: the leading digit gets an n prefix and the space becomes an underscore. Check the warning strip if your output element names look different from your input keys.

Frequently Asked Questions

Each array entry becomes its own element, repeated under the same tag name as the array's key. { "tag": ["a", "b"] } becomes <tag>a</tag><tag>b</tag>, not a single element holding both values.

If the JSON value has exactly one top-level key, that key becomes the root element. Otherwise the root uses the Root name field, which defaults to root.

Prefix the key with @_ in your JSON, such as { "@_id": "42" }. The converter writes it as an attribute on the enclosing element rather than a nested tag.

No. XML has no native number or boolean type, so 42 and true are written as plain text and come back as strings if you convert the XML to JSON again.

Invalid characters, including spaces, are replaced with underscores, and a key starting with a digit gets an n prefix. The warning strip below the output shows the exact rename.

Jump straight to a conversion

Full Data Format Converter tool

Explore Our Tools

Browse all tools