JSON to XML

Input
Output

JSON to XML Converter

Convert JSON into well-formed XML with a root element you choose, or switch direction to turn XML into JSON with numbers and booleans detected.

Example: JSON with attributes, text and a list

Keys starting with @ become attributes and #text becomes the element's text, the same convention XML to JSON uses, so the two directions round-trip. The array becomes repeated item elements, and the < > & in the note are escaped:

Input

{
  "order": {
    "@id": "ORD-20419",
    "customer": "Ananya Rao",
    "item": [
      {
        "@sku": "KB-01",
        "#text": "Keyboard"
      },
      {
        "@sku": "MS-02",
        "#text": "Mouse"
      }
    ],
    "note": "Leave at <gate> & ring"
  }
}

Output

<?xml version="1.0" encoding="UTF-8"?>
<order id="ORD-20419">
  <customer>Ananya Rao</customer>
  <item sku="KB-01">Keyboard</item>
  <item sku="MS-02">Mouse</item>
  <note>Leave at &lt;gate&gt; &amp; ring</note>
</order>

How do I use the JSON to XML?

  1. Paste JSON, or choose XML → JSON and paste XML.
  2. Set the root element name if you need a particular one.
  3. Copy the result or save it to a file.

What does the JSON to XML do?

  • Both directions: JSON to XML and XML to JSON
  • Choose the root element
  • Detect numbers and booleans, or keep every value as text
  • Opens .xml files directly

When to use the JSON to XML

Some systems only take XML: SOAP endpoints, older enterprise and banking integrations, payment gateways and many government APIs. Converting JSON to XML gives you a well-formed document to send or to test with, with a root element you choose.

Objects become elements and arrays become repeated elements named after their key. Keys starting with @ become attributes and #text becomes an element's text, the same convention XML to JSON uses, so a document survives the round trip. Text is escaped (< > &), keys that aren't valid XML names are fixed (first name becomes first_name, 1st becomes _1st), and a top-level array becomes item elements inside the root.

Frequently asked questions

How do I make an attribute?
Start the key with @: {"order": {"@id": "ORD-1"}} gives <order id="ORD-1"/>. Use #text for the element's own text next to attributes.
Why was my key renamed?
XML names can't contain spaces or start with a digit, so first name becomes first_name and 1st becomes _1st. Rename the keys in the JSON if the receiver expects other names.
How are arrays converted to XML?
Each array item becomes a repeated element with the array's key as its name.
Can I convert XML to JSON?
Yes. Change Direction to XML → JSON.
Is my data uploaded?
No. The conversion happens on your device.

More JSON tools

Bracely has 108 JSON tools in one page. Related ones:

Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.7 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram