XML to JSON Converter

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

Extensible Markup Language (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 most common data interchange format on the web. Douglas Crockford first released the JSON specification in the early 2000s. It is a simple format that is easier to comprehend than XML. It is also smaller in size because it does not have closing tags. A wide variety of programming languages can parse JSON files. They also support the serialization of data structures to JSON. You can copy JSON text to JavaScript and start using them without any modifications.

Settings Explained
  • 1. Indent

    This setting governs whether or not the Output is indented. The indented Output is easier to comprehend. On the other hand, a non-indented output is compact. The smaller size is best for transmission over the network. So, we often minify JSON by removing non-essential whitespace.

    Indentation On

    {
      "name": "John Doe",
      "age": 69
    }
    Indentation Off

    {"name":"John Doe","age":69}
  • 2. 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"
        }
      ]
    }
  • 3. 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"
        }
      ]
    }
  • 4. 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"
        }
      ]
    }
Comments 0

History
May 14, 2018
Tool Launched