# XML to JSON API

> XML to JSON is an XML to JSON converter API that turns raw XML strings into structured JSON objects. Send any valid XML payload to receive an organized JSON tree preserving tags, attributes, and child elements.

**Endpoint:** `POST https://api.apiverve.com/v1/xmltojson`  
**Category:** Data Conversion  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/xmltojson

## Overview

When you need to change XML to JSON inside an app or pipeline, POST the XML and read back JSON. The XML to JSON API parses the document and returns it as a nested JSON object that mirrors the element tree, with the root element as the top-level key, child elements in order and text content kept alongside them, so you can work with old SOAP responses, RSS feeds, sitemaps or config files using ordinary JSON tooling.

Integration developers use it when a partner, government feed or legacy system only speaks XML but the rest of the stack expects JSON, and in no-code tools where parsing XML by hand is awkward. Badly formed input is reported as an error with the parser's message rather than producing a half-converted object.

There is no plan difference: the Free plan and paid plans run the same conversion and return the same output.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/xmltojson" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n  <to>Tove</to>\n  <from>Jani</from>\n  <heading>Reminder</heading>\n  <body>Don'\''t forget me this weekend!</body>\n</note>"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `xml` | string | Yes | The XML content to convert to JSON |

## Response fields

- `note` — object · Root element converted from XML structure
    - `note.children.0.to` — object
      - `note.children.0.to.content` — string · Recipient field value from XML element

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "note": {
      "children": [
        {
          "to": {
            "content": "Tove"
          }
        },
        {
          "from": {
            "content": "Jani"
          }
        },
        {
          "heading": {
            "content": "Reminder"
          }
        },
        {
          "body": {
            "content": "Don't forget me this weekend!"
          }
        }
      ]
    }
  }
}
```

## Use cases

- **Legacy SOAP Integration** — When ingesting legacy SOAP web service responses, modern frontend microservices parse the returned XML body into JSON before processing client requests.
- **RSS Feed Ingestion** — News aggregators translate incoming XML syndication feeds into standard JSON records to index articles directly into document databases.
- **Supply Chain Invoices** — To process electronic data interchange documents, logistics platforms convert supplier XML invoices into JSON payloads for internal billing services.
- **Webhook Payload Normalization** — Convert XML notifications from payment gateways and partner APIs into JSON before passing event payloads to serverless event brokers.

## SDKs

- **npm** — `npm install @apiverve/xmltojson` (https://www.npmjs.com/package/@apiverve/xmltojson)
- **NuGet** — `dotnet add package APIVerve.API.XMLtoJSON` (https://www.nuget.org/packages/APIVerve.API.XMLtoJSON)
- **Source** — https://github.com/apiverve/xmltojson-api

## More

- Full reference: https://docs.apiverve.com/ref/xmltojson
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
