XML to JSON Library Comparison

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

xml2js

{
  "catalog": {
    "product": [
      {
        "$": {
          "description": "Cardigan Sweater",
          "product_image": "cardigan.jpg"
        },
        "catalog_item": [
          {
            "$": {
              "gender": "Men's"
            },
            "item_number": [
              "QWZ5671"
            ],
            "price": [
              "39.95"
            ],
            "size": [
              {
                "$": {
                  "description": "Medium"
                },
                "color_swatch": [
                  {
                    "_": "Red",
                    "$": {
                      "image": "red_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Burgundy",
                    "$": {
                      "image": "burgundy_cardigan.jpg"
                    }
                  }
                ]
              },
              {
                "$": {
                  "description": "Large"
                },
                "color_swatch": [
                  {
                    "_": "Red",
                    "$": {
                      "image": "red_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Burgundy",
                    "$": {
                      "image": "burgundy_cardigan.jpg"
                    }
                  }
                ]
              }
            ]
          },
          {
            "$": {
              "gender": "Women's"
            },
            "item_number": [
              "RRX9856"
            ],
            "price": [
              "42.50"
            ],
            "size": [
              {
                "$": {
                  "description": "Small"
                },
                "color_swatch": [
                  {
                    "_": "Red",
                    "$": {
                      "image": "red_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Navy",
                    "$": {
                      "image": "navy_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Burgundy",
                    "$": {
                      "image": "burgundy_cardigan.jpg"
                    }
                  }
                ]
              },
              {
                "$": {
                  "description": "Medium"
                },
                "color_swatch": [
                  {
                    "_": "Red",
                    "$": {
                      "image": "red_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Navy",
                    "$": {
                      "image": "navy_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Burgundy",
                    "$": {
                      "image": "burgundy_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Black",
                    "$": {
                      "image": "black_cardigan.jpg"
                    }
                  }
                ]
              },
              {
                "$": {
                  "description": "Large"
                },
                "color_swatch": [
                  {
                    "_": "Navy",
                    "$": {
                      "image": "navy_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Black",
                    "$": {
                      "image": "black_cardigan.jpg"
                    }
                  }
                ]
              },
              {
                "$": {
                  "description": "Extra Large"
                },
                "color_swatch": [
                  {
                    "_": "Burgundy",
                    "$": {
                      "image": "burgundy_cardigan.jpg"
                    }
                  },
                  {
                    "_": "Black",
                    "$": {
                      "image": "black_cardigan.jpg"
                    }
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}