XML to JSON Converter

Updated: May 14, 2018

XML to JSON Converter is used to convert XML data or file into JSON format. The converter converts XML attributes, elements & text nodes into JSON properties. When possible elements are converted into arrays. The JSON output can be indented for easier viewing.

Input: Paste XML content below



Settings

XML is a widely used language that was once the de facto standard for data interchange between applications. Since the advent of JSON, however, it has lost the advantage to the more simple nature of JSON. Nevertheless, XML is still used by applications and SOAP based web services

JavaScript Object Notation (JSON) pronounced as "Jason" is the de facto standard for data interchange on the web these days. It is a simple format that is easier to comprehend than XML. It also has less size than XML because of no closing tags. Interacting with JSON from JavaScript is extremely seamless.

Indent
This setting governs whether or not the output is indented. The indented output is easier for humans to comprehend. On the other hand, a non-indented output is compact & smaller in size (best for transmission). So, JSON is often minified which compacts & compresses the output by removing non-essential whitespace.
Indentation On
{
  "name": "John Doe",
  "age": 69
}
Indentation Off
{"name":"John Doe","age":69}
Flatten Arrays
If selected, arrays are flattened when possible.
Input XML
<catalog>
  <book>
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
  </book>
  <book>
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
  </book>
</catalog>
Flatten Arrays On
[
  {
    "author": "Gambardella, Matthew",
    "title": "XML Developer's Guide"
  },
  {
    "author": "Ralls, Kim",
    "title": "Midnight Rain"
  }
]
Flatten Arrays Off
{
  "book": [
    {
      "author": "Gambardella, Matthew",
      "title": "XML Developer's Guide"
    },
    {
      "author": "Ralls, Kim",
      "title": "Midnight Rain"
    }
  ]
}
Attribute Prefix
The prefix to use for properties corresponding to XML attributes. Set blank to use no prefix
Input XML
<catalog>
  <book id="1">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
  </book>
  <book id="2">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
  </book>
</catalog>
Attribute Prefix: @
{
  "book": [
    {
      "@id": "1",
      "author": "Gambardella, Matthew",
      "title": "XML Developer's Guide"
    },
    {
      "@id": "2",
      "author": "Ralls, Kim",
      "title": "Midnight Rain"
    }
  ]
}
Attribute Prefix: Empty
{
  "book": [
    {
      "id": "1",
      "author": "Gambardella, Matthew",
      "title": "XML Developer's Guide"
    },
    {
      "id": "2",
      "author": "Ralls, Kim",
      "title": "Midnight Rain"
    }
  ]
}
Text Property Name
The name of the property that holds the value of XML text nodes
Input
<catalog>
  <book>
    <author>Gambardella, Matthew</author>
    XML Developer's Guide
  </book>
  <book>
    <author>Ralls, Kim</author>
    Midnight Rain
  </book>
</catalog>
Text Property Name: #text
{
  "book": [
    {
      "author": "Gambardella, Matthew",
      "#text": "XML Developer's Guide"
    },
    {
      "author": "Ralls, Kim",
      "#text": "Midnight Rain"
    }
  ]
}
 
Created: May 14, 2018
Online Tool Designed For: Windows, OS X, Android, iOS, Linux