JSON to XML

Convert JSON to a clean XML representation.

Open tool

Overview

The JSON-to-XML converter rewrites a JSON document into an equivalent XML representation. Object keys become element names, scalar values become element text, and arrays become repeated sibling elements with the same tag.

It's the right tool when bridging a JSON-producing service to an XML-consuming one — for SOAP endpoints, RSS-style outputs, or legacy enterprise integrations. Developers maintaining hybrid systems use a json to xml converter to skip writing custom transformation code.

How it works

XML has no native equivalent for JSON arrays — repetition is the convention. The converter emits one element per array item, all sharing the same tag, so an array property tags: ["a","b"] becomes <tags>a</tags><tags>b</tags>. JSON keys that aren't valid XML element names (starting with digits, containing spaces or special characters) are escaped using a configurable scheme: replace with underscores, or wrap in an <entry name="..."> element.

Scalar values render as element text. Boolean and number values are written in their canonical JSON form (true, false, 42). Null values produce an empty element with the conventional xsi:nil="true" attribute on opt-in, or a plain empty tag otherwise. A root element wraps everything since XML requires a single root.

Examples

Input:
{ "user": { "name": "Alice", "tags": ["admin","ops"] } }
Output:
<root>
  <user>
    <name>Alice</name>
    <tags>admin</tags>
    <tags>ops</tags>
  </user>
</root>
Input:
{ "active": true, "score": null }
<root>
  <active>true</active>
  <score xsi:nil="true" />
</root>

FAQ

Is the round trip lossless via XML-to-JSON?

Not always. JSON arrays of one element are indistinguishable from a single value when serialised to repeated XML elements — both round-trip into the same shape. Mark single-element arrays explicitly if you need to preserve their cardinality.

Can I get attributes instead of child elements?

Yes — designate certain keys (by prefix like @type or by config) to be serialised as attributes on the parent element instead of nested elements.

What about namespaces?

Namespace prefixes can be configured globally so the output uses <ns:user> and declares xmlns:ns on the root. Per-element namespacing is not supported automatically.

Try JSON to XML

An unhandled error has occurred. Reload ×