Developer Tools

XML to JSON converter.

Paste XML and get JSON, or paste JSON and get XML. Attributes, repeated elements, CDATA and entities are handled, and a malformed document tells you the line and column. Nothing leaves your browser.

Advertisement

Input

Converted output

Paste XML or JSON to convert it.

About this XML to JSON converter

XML and JSON do not map one-to-one: XML has attributes, mixed text and ordered repeated elements, while JSON has objects, arrays and typed scalars. This converter uses one fixed, reversible convention so the result is predictable.

Worked example

<order id="7">
  <item sku="A1">Widget</item>
  <item sku="B2">Gadget</item>
</order>

becomes

{
  "order": {
    "@id": "7",
    "item": [
      { "@sku": "A1", "#text": "Widget" },
      { "@sku": "B2", "#text": "Gadget" }
    ]
  }
}

Rules used

Limits

FAQ

Why is one element an object but two elements an array?

JSON has no way to know a single element could repeat. A lone child is an object and repeated siblings become an array. If your code needs an array every time, wrap it: [].concat(value).

Where did my XML attributes go?

They are keys that start with @, next to the element's children. Text sits under #text when an element has attributes or children.

Is my XML uploaded?

No. Parsing and conversion run in your browser and nothing is sent to a server.

Source

Advertisement
Advertisement
Listening…