JSON to XML

Runs in browser JSON & Data

Produce XML from JSON with configurable root element, array item names and attribute handling. Special characters are escaped correctly.

Privacy: This tool runs entirely in your browser. Your input never leaves your device.
Loading tool…

How to use JSON to XML

  1. Paste the JSON document (use @_name keys for attributes if needed).
  2. Set the root and item element names and the formatting style.
  3. Copy or download the XML.

JSON to XML features

  • Configurable root element and array item element names
  • @_ prefixed keys become attributes, "#text" becomes element text
  • Arrays repeat elements; top-level arrays are wrapped automatically
  • Invalid element names are sanitised so the output is always well-formed
  • Special characters escaped as XML entities
  • Pretty-printed or compact output, optional XML declaration

JSON to XML example

Object with attributes and a list

Input:

{"order":{"@_id":"1001","items":[{"sku":"KB-100"},{"sku":"MS-220"}]}}

Output:

<?xml version="1.0" encoding="UTF-8"?>
<order id="1001">
  <items>
    <sku>KB-100</sku>
  </items>
  <items>
    <sku>MS-220</sku>
  </items>
</order>

Frequently asked questions about JSON to XML

How do I produce XML attributes?

Prefix a key with @_ (for example "@_id": "42") and it becomes an attribute of the parent element. Use "#text" for the text content of an element that also has attributes.

How are arrays converted?

An array under a key repeats that element once per item (<tag>a</tag><tag>b</tag>). A top-level array is wrapped in the root element with one item element per entry — both names are configurable.

What if a key is not a valid XML name?

Invalid characters are replaced by underscores and names that start with a digit get a leading underscore, so the output is always well-formed.

Are special characters escaped?

Yes. &, <, >, quotes and apostrophes in values and attributes are escaped as XML entities.