Skip to content
UniKit

JSON to XML

Convert JSON to XML with a configurable root name, array wrapping, attribute prefix (@) and text node (#text), plus indentation, XML declaration, CDATA and automatic escaping.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

JSON

Options

A root level array is always wrapped with the array item name so the output has a single root element.

Array style
XML output

What this tool does

  • Feed a JSON payload to legacy systems that only speak XML — SOAP endpoints, banking or government integrations, configuration files.
  • JSON keys starting with @ become XML attributes and a #text key becomes the element content, so id="7" and text nodes survive the round trip.
  • A root-level array is wrapped with the array item name automatically, guaranteeing exactly one root element — otherwise XML parsers reject the document outright.
  • Angle brackets and ampersands in text are escaped for you, and CDATA is available for content you would rather not escape by hand.

Example

Input

{"name":"Tom","tags":["a","b"]}

Output

<root>
  <name>Tom</name>
  <tags>
    <item>a</item>
    <item>b</item>
  </tags>
</root>

Defaults are root element root, array item name item and 2-space indent; arrays are wrapped in <item>, or you can switch to repeating the parent element name.

Frequently asked questions

What is the @ and #text convention?

It is the usual JSON↔XML mapping: a key starting with @ becomes an XML attribute (@id turns into id="7") and a key equal to #text becomes the element text. Both the prefix and the text key name are configurable — clearing the prefix treats every key as a child element.

What is the difference between wrapping in <item> and repeating the parent name?

Wrapping produces <tags><item>a</item></tags>, which is explicit but adds a level; repeating the parent name produces <tag>a</tag><tag>b</tag>, which matches some XML dialects better. A root-level array is always wrapped with the item name either way so the output has a single root.

Why is my text escaped in the output?

<, > and & are reserved in XML and must be written as &lt;, &gt; and &amp; inside text, otherwise the document is invalid. When the content is markup-heavy and you would rather not escape it, enable CDATA to emit <![CDATA[...]]>.

Can a JSON key with spaces or Chinese characters be an element name?

Not directly. XML element names only allow letters, digits, underscores, dots and hyphens, so illegal characters become -, and names starting with a digit, dot or hyphen get the item-name prefix. The result is always valid but may differ slightly from the original key.

Is my JSON uploaded anywhere?

No. The conversion runs entirely in your browser with no network requests, and it works offline.

Keywords:json to xmljson xml 转换xml转换converterattribute#textcdata数据格式

Related tools