Handitab

JSON to XML

Convert JSON to indented XML with a root element name you choose, turning object keys into elements and arrays into repeated elements.

About JSON to XML

JSON to XML conversion maps a JSON tree onto XML elements. Here each object key becomes an element, each array item repeats the element of its key, and primitive values become escaped text. Keys that are not valid XML names are replaced with the name item. The output starts with an XML 1.0 UTF-8 declaration and uses two-space indentation. No attributes are generated, and null becomes an empty element.

How to use JSON to XML

  1. Type or paste into the "JSON" box, or press "Use example" to try it with sample data.
  2. Set "Root element name" if the defaults do not fit.
  3. The result appears below and updates as you type.
  4. Copy the result with the copy button, or download it as a file where that is offered.

Questions about JSON to XML

Why does a top-level JSON array give XML with several root elements?

Each array item is written as its own element with the root name, and XML allows only one root. Wrap the array in an object, for example {"items": [...]}, to get a single root element.

Runs in your browser. Page last updated .

More encoding and data tools

All 28 encoding and data tools