JSON to XML Converter

Convert JSON to XML in your browser. Objects become nested elements, arrays repeat their tag, and text is safely escaped.

Independently verified for accuracy

Calculator by Toolsloft ↗

Convert a JSON object or array into XML with a wrapping root element. Object properties become nested tags, array items repeat their tag, and reserved characters are escaped so the output is well-formed. Handy when a system expects XML but you have JSON on hand.

How this is calculated

The JSON is parsed, then serialized to XML with a fixed convention: each object property becomes a child element named after its key, each array item repeats the parent tag, null becomes an empty element, booleans and numbers use their JSON text, and the characters &, <, and > in string values are escaped. Everything is wrapped in a single root element you can name.

How to use

  1. Paste your JSON into the input box.
  2. Set the name for the root element, or keep the default.
  3. Copy the XML from the output box.

Examples

  • Object: {"name":"Al"} becomes <root><name>Al</name></root>
  • Array: {"tags":["a","b"]} repeats the tag

FAQ

How are arrays represented in the XML?
Each item in an array repeats the element name of the property that holds it. So {"tags":["a","b"]} becomes <tags>a</tags><tags>b</tags>, which is the standard way to show a list in XML.
Why is there a root element?
XML documents must have a single top-level element. Wrapping the output in one root element keeps the result well-formed even when your JSON is an array or a single value.
What happens to special characters?
The characters that have meaning in XML, namely &, <, and >, are replaced with their entities (&amp;, &lt;, &gt;) inside text so the output parses correctly.

Embed this calculator

Add this free calculator to your own site. Copy the code and paste it where you want it to appear.