DevsToolkit

XML to JSON

XML

Convert XML data to JSON representation

All processing happens locally in your browser — your data never leaves your machine.
Loading tool...

Examples

Simple Element

Input
<greeting>Hello, World!</greeting>
Output
{
  "greeting": "Hello, World!"
}

Nested with Attributes

Input
<catalog><book id="1" genre="fiction"><title>The Great Gatsby</title><author>F. Scott Fitzgerald</author><price currency...
Output
{
  "catalog": {
    "book": [
      {
        "@attributes": {
          "id": "1",
          "genre": "fiction"
      ...

With CDATA Section

Input
<script><![CDATA[function hello() { return "world"; }]]></script>
Output
{
  "script": "function hello() { return \"world\"; }"
}

Frequently Asked Questions

How does the XML to JSON converter handle attributes?
XML attributes are placed under an "@attributes" key in the resulting JSON object. For example, <book id="1"> becomes { "book": { "@attributes": { "id": "1" } } }. Elements with only text content and no attributes are simplified to just the string value.
What happens with repeated XML elements?
When multiple sibling elements share the same tag name, they are automatically grouped into a JSON array. For example, multiple <item> elements inside a parent will become an array under the "item" key.
Is my XML data safe when using this tool?
Yes. All conversion is performed locally in your browser using JavaScript. Your XML data never leaves your machine and is not sent to any server.

Related Tools