JSON to XML Converter

Skip to editor
Explorer
Open Files

No files open

0 files open

jsoneditor.io v2

{
  "orderId": "ord_8F2K1",
  "status": "shipped",
  "customer": {
    "id": 4182,
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "items": [
    {
      "sku": "KB-104",
      "name": "Mechanical keyboard",
      "qty": 1,
      "price": 89.99
    },
    {
      "sku": "MS-220",
      "name": "Wireless mouse",
      "qty": 2,
      "price": 24.5
    }
  ],
  "total": 138.99,
  "paid": true,
  "notes": null
}
JSONUTF-8
Spaces: 2

How do I convert JSON to XML?

To convert JSON to XML, paste it above, open Convert and press To XML. Each key becomes an element, arrays become repeated elements with the same name, and the result is indented and starts with an XML declaration.

Keys that start with @ become attributes and a #text key becomes the element's text, the same convention XML to JSON produces, so a document survives the round trip. Keys that aren't valid XML names, like ones with spaces or a leading digit, are cleaned up so the output always parses.

  1. Paste your JSON into the editor.
  2. Open Convert and press To XML.
  3. Copy the XML or press Save.

Example

JSON
{
  "orderId": "ord_8F2K1",
  "status": "shipped",
  "customer": {
    "id": 4182,
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "items": [
    {
      "sku": "KB-104",
      "name": "Mechanical keyboard",
      "qty": 1,
      "price": 89.99
    },
    {
      "sku": "MS-220",
      "name": "Wireless mouse",
      "qty": 2,
      "price": 24.5
    }
  ],
  "total": 138.99,
  "paid": true,
  "notes": null
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<order>
  <orderId>ord_8F2K1</orderId>
  <status>shipped</status>
  <customer>
    <id>4182</id>
    <name>Ada Lovelace</name>
    <email>ada@example.com</email>
  </customer>
  <items>
    <sku>KB-104</sku>
    <name>Mechanical keyboard</name>
    <qty>1</qty>
    <price>89.99</price>
  </items>
  <items>
    <sku>MS-220</sku>
    <name>Wireless mouse</name>
    <qty>2</qty>
    <price>24.5</price>
  </items>
  <total>138.99</total>
  <paid>true</paid>
  <notes/>
</order>

Questions people ask

How are JSON arrays converted to XML?

XML has no arrays, so every item becomes an element with the array's key as its name, one after another. An array at the very top level becomes a list of item elements inside the root.

Can I create XML attributes from JSON?

Yes, prefix the key with @. {"order": {"@id": "42"}} becomes <order id="42"/>.

Is my data uploaded anywhere?

No, this runs entirely in your browser, so nothing you paste is sent to a server. The only feature that sends data anywhere is the optional AI assistant, and only when you actually ask it something.