XML to JSON Library Comparison

Example XML tXml tXml Simplified xml-js xml-js Compact fast-xml-parser w/o ignoreAttributes xml2js

xml-js Compact

{
  "_declaration": {
    "_attributes": {
      "version": "1.0"
    }
  },
  "_instruction": {
    "xml-stylesheet": "href=\"catalog.xsl\" type=\"text/xsl\""
  },
  "_doctype": "catalog SYSTEM \"catalog.dtd\"",
  "catalog": {
    "product": {
      "_attributes": {
        "description": "Cardigan Sweater",
        "product_image": "cardigan.jpg"
      },
      "catalog_item": [
        {
          "_attributes": {
            "gender": "Men's"
          },
          "item_number": {
            "_text": "QWZ5671"
          },
          "price": {
            "_text": "39.95"
          },
          "size": [
            {
              "_attributes": {
                "description": "Medium"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "red_cardigan.jpg"
                  },
                  "_text": "Red"
                },
                {
                  "_attributes": {
                    "image": "burgundy_cardigan.jpg"
                  },
                  "_text": "Burgundy"
                }
              ]
            },
            {
              "_attributes": {
                "description": "Large"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "red_cardigan.jpg"
                  },
                  "_text": "Red"
                },
                {
                  "_attributes": {
                    "image": "burgundy_cardigan.jpg"
                  },
                  "_text": "Burgundy"
                }
              ]
            }
          ]
        },
        {
          "_attributes": {
            "gender": "Women's"
          },
          "item_number": {
            "_text": "RRX9856"
          },
          "price": {
            "_text": "42.50"
          },
          "size": [
            {
              "_attributes": {
                "description": "Small"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "red_cardigan.jpg"
                  },
                  "_text": "Red"
                },
                {
                  "_attributes": {
                    "image": "navy_cardigan.jpg"
                  },
                  "_text": "Navy"
                },
                {
                  "_attributes": {
                    "image": "burgundy_cardigan.jpg"
                  },
                  "_text": "Burgundy"
                }
              ]
            },
            {
              "_attributes": {
                "description": "Medium"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "red_cardigan.jpg"
                  },
                  "_text": "Red"
                },
                {
                  "_attributes": {
                    "image": "navy_cardigan.jpg"
                  },
                  "_text": "Navy"
                },
                {
                  "_attributes": {
                    "image": "burgundy_cardigan.jpg"
                  },
                  "_text": "Burgundy"
                },
                {
                  "_attributes": {
                    "image": "black_cardigan.jpg"
                  },
                  "_text": "Black"
                }
              ]
            },
            {
              "_attributes": {
                "description": "Large"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "navy_cardigan.jpg"
                  },
                  "_text": "Navy"
                },
                {
                  "_attributes": {
                    "image": "black_cardigan.jpg"
                  },
                  "_text": "Black"
                }
              ]
            },
            {
              "_attributes": {
                "description": "Extra Large"
              },
              "color_swatch": [
                {
                  "_attributes": {
                    "image": "burgundy_cardigan.jpg"
                  },
                  "_text": "Burgundy"
                },
                {
                  "_attributes": {
                    "image": "black_cardigan.jpg"
                  },
                  "_text": "Black"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}