JSON to XML — Guide

Convert JSON data to XML format.

What it is and when to use it

XML is still the interchange format for a lot of enterprise, payment and SOAP-style systems, even though JSON won. This tool maps a JSON value onto an XML document: objects become elements with a child element per key, arrays become repeated elements sharing the same tag name, and scalar values become text content. Because XML and JSON model data differently — XML has no native array or boolean type — the conversion makes a set of reasonable choices (booleans and numbers become string text, for instance), and the XML-to-JSON tool reverses it when you receive XML back.

Converts JSON into XML, for integrating with older systems that only accept XML.

How to use it

  1. Paste the JSON
  2. Get the XML result
  3. Copy and use it

A worked example

Fill in sample JSON

{ "user": { "id": 1, "name": "Alice" } }

Copy this into the tool, or open JSON to XML

Things that trip people up

  • XML has no concept of arrays, so lists become repeated tags

Questions people ask

How are arrays represented in XML?
An array of values becomes several sibling elements that share the same tag name. [1, 2, 3] under the key "item" becomes <item>1</item><item>2</item><item>3</item>. There is no XML array type, so the repeated-tag convention is the standard way to round-trip a list.
What happens to the root element?
XML documents need exactly one root element, but top-level JSON may be an object, array or scalar. This tool wraps the output in a root element (commonly <root>) so the result is always well-formed XML; rename it to match the schema your consumer expects.
Is the conversion reversible?
With caveats. Converting XML back to JSON again loses the distinction XML never had — there is no native boolean or number, everything is text — so 1 may come back as the string "1". Keep the original JSON if you need exact types round-tripped.

Next steps

Open the JSON to XML tool

Spotted something wrong on this page? Tell us via Contact Us