{ } JSON Workbench100% Private • Zero Server Uploads

"JSON to XML Converter":{ }

Convert JSON to XML in your browser. Paste JSON, get well-formed XML instantly: keys become elements, arrays become repeated elements, and special characters are escaped automatically. 100% client-side with repair-aware parsing that tolerates trailing commas and comments.

Comparing the formats? See JSON vs XML. Reverse it with XML to JSON.

What is JSON to XML conversion?

JSON to XML conversion transforms JSON's key-value and array structure into hierarchical XML elements. Keys become element tags, nested objects become nested elements, and arrays become repeated sibling elements. It's needed to integrate with XML-based enterprise systems, SOAP APIs, and legacy applications that still require XML for data exchange.

This converter is powered by fast-xml-parser and runs 100% in your browser and nothing is uploaded, so your payloads never leave your machine.

Edge cases & gotchas

  • Arrays map to repeated sibling elements, not a container plus items.
  • Multiple top-level keys (or a non-object root) require a synthetic <root> wrapper because XML allows only one root.
  • Keys starting with digits or containing spaces are not valid XML tag names and get sanitized.
  • null → empty/self-closing element; empty string → empty element.
  • Numbers and booleans become text nodes, so type information is lost.
  • Special characters are escaped, not CDATA-wrapped, by default.

JSON → XML mapping reference

JSONXML
{ "k": "v" }<k>v</k>
{ "@_attr": "v" }attr="v" (attribute)
{ "#text": "v" }element text value
[a, b]repeated <key>a</key><key>b</key>
null<key/> (empty)
number / booleantext node
multiple top-level keyswrapped in <root>

How to use

  1. Paste or type JSON into the Input pane, or upload a .json file.
  2. Set options: root element name, array item name, indentation, and whether to include the XML declaration.
  3. Well-formed XML renders live in the Output pane.
  4. Copy the result or download it as a .xml file.
  5. Malformed JSON? Repair-aware parsing fixes trailing commas and comments before converting.

Examples

Basic object → nested elements

Input
{ "user": { "id": 1, "name": "Ada" } }
Output
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <id>1</id>
    <name>Ada</name>
  </user>
</root>

Array → repeated elements (edge case)

Input
{ "colors": ["red", "green", "blue"] }
Output
<root>
  <colors>red</colors>
  <colors>green</colors>
  <colors>blue</colors>
</root>

Attributes + special characters

Input
{ "note": { "@_lang": "en", "#text": "Tom & Jerry <3" } }
Output
<note lang="en">Tom &amp; Jerry &lt;3</note>

FAQ

How do JSON arrays convert to XML?

Each array item becomes a repeated element sharing the same tag name. XML has no native array type, so there is no container, just siblings.

How do I create XML attributes from JSON?

Prefix the key with @_ (the fast-xml-parser convention), e.g. "@_id": "5" → id="5". Use #text to set the element's text value alongside attributes.

Is JSON to XML conversion lossless?

No. XML has constructs (attributes, namespaces, comments, mixed content) with no JSON equivalent, so a full round-trip is not guaranteed. Use XML to JSON for the inverse.

What is the root element and can I rename it?

XML requires a single root. A non-object root or multiple top-level keys are wrapped in a default <root> element, which you can rename.

How are null values handled?

null becomes an empty/self-closing element, e.g. <key/>. An empty string produces an empty element too.

Are special characters escaped?

Yes. &, <, > and attribute quotes are escaped to keep the XML well-formed. Content is not wrapped in CDATA by default.

Related tools