JSON to XML Converter

Data Tools

Paste JSON and get well-formed, indented XML, with attributes, text and arrays mapped by clear rules.

Options
JSON
XML

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the JSON to XML Converter does

The JSON to XML Converter writes a JSON document as well-formed, indented XML. Keys starting with @ become attributes and #text becomes element text, the same convention the XML to JSON converter uses, so a round trip keeps attributes. Arrays are wrapped in their key's element with one item element per entry, and keys that are not valid XML names are fixed and listed.

Steps

How to use it

  1. 1Paste JSON or upload a .json file.
  2. 2Set the root element, the array item name and the indent if needed.
  3. 3Press Convert, then copy or download the .xml file.

Example

A real run

Input

{
  "order": {
    "@id": "A-1001",
    "customer": "Ada Lovelace",
    "items": [
      {"sku": "TX-1", "qty": 2, "price": 14.99},
      {"sku": "CA-2", "qty": 1, "price": 35}
    ]
  }
}

Output

<?xml version="1.0" encoding="UTF-8"?>
<order id="A-1001">
  <customer>Ada Lovelace</customer>
  <items>
    <item>
      <sku>TX-1</sku>
      <qty>2</qty>
      <price>14.99</price>
    </item>
    <item>
      <sku>CA-2</sku>
      <qty>1</qty>
      <price>35</price>
    </item>
  </items>
</order>

The single key order becomes the root, @id becomes an attribute, and the items array is wrapped in <items> with one <item> per entry.

Options

Every setting, and when to use it

Root element
Left empty, a JSON object with a single key uses that key as the root, so {"order": {...}} becomes <order>. Otherwise everything goes inside <root>, or the name you type.
Array item element and Wrap arrays
With wrapping on, "items": [...] becomes <items><item>…</item></items>, the shape most XML schemas use. Off, each entry repeats the key's element, <items>…</items><items>…</items>.
XML declaration and Indent
The declaration line <?xml version="1.0" encoding="UTF-8"?> is expected by most consumers; turn it off when embedding the XML in another document. Indent with 2 or 4 spaces or tabs.

Good to know

Common problems and limits

Input up to 5 MB. Keys that are not valid XML names, such as 2fa or keys with spaces, are changed (for example to _2fa) and listed in a note.

Values are escaped (& becomes &amp;), null becomes an empty element, and numbers and booleans are written as text, because XML has no types.

Check the result with the XML Formatter, or convert it back with XML to JSON.

Audience

Who uses it

  • Integration developersFeed JSON from a modern API into a SOAP service, an EDI gateway or an older system that only accepts XML.
  • Ecommerce teamsBuild an XML product feed or order export for a marketplace or a shipping partner from JSON data.
  • DevelopersGenerate XML test fixtures or configuration from JSON you already have.

FAQ

Frequently asked

How are JSON arrays converted to XML?

XML has no arrays, so each entry becomes its own element. With Wrap arrays on, "items": [a, b] becomes <items><item>a</item><item>b</item></items>; the item name is configurable. A top-level array becomes repeated item elements inside the root.

How do I create XML attributes from JSON?

Prefix the key with @: {"order": {"@id": "A-1001"}} becomes <order id="A-1001">. A #text key sets the element's text next to its attributes, so {"price": {"@currency": "USD", "#text": 35}} becomes <price currency="USD">35</price>.

Is there a standard JSON to XML mapping?

No. Several conventions exist, such as BadgerFish, Parker and JsonML, and libraries differ. This page uses the widely used @ and #text convention; Python's xmltodict uses the same prefixes, so its output converts back the same way.

How do I convert JSON to XML in Python?

With xmltodict: xmltodict.unparse({"order": data}, pretty=True). It needs a single root key, and it repeats elements for lists instead of wrapping them, which matches this page with Wrap arrays off.

Why were some key names changed?

XML element names cannot start with a digit or contain spaces and most punctuation, while JSON keys can be anything. Invalid characters become underscores and a leading digit gets an underscore in front; the note lists every change.

Is my JSON sent anywhere?

No. The XML is built in your browser. A copy of each conversion is saved to your past runs so you can reopen it.

Automation: an MCP tool json_to_xml(json, options) → xml and an n8n node are planned for this tool.

All data tools →
GuideJSON, YAML, TOML and XML: which format when →When to use JSON, YAML, TOML or XML: what each is good at, the traps (YAML's no, JSON's big numbers, XML attributes) and how to convert between them.
Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai