Convert a SOAP XML Response to JSON (With Namespaces)

Turn a SOAP envelope into clean JSON: extract the Body, strip namespace prefixes, keep one-item lists as arrays, and generate TypeScript types or an XSD.

Convert only the SOAP Body

A SOAP response wraps the data you need in an Envelope and a Body, often with a Header beside it. Paste the response into XML to JSON. When the root is a SOAP Envelope, the tool offers Convert only the Body, which sets Start at element to Envelope/Body and drops the wrapper.

Without other changes, namespace prefixes and xmlns declarations stay in the keys, so no information is lost. The quantity text sits under #text because the Line element also has an attribute.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <m:GetOrderResponse xmlns:m="urn:shop">
      <m:Order id="A1">
        <m:Line sku="BK-42">2</m:Line>
      </m:Order>
    </m:GetOrderResponse>
  </soap:Body>
</soap:Envelope>

{
  "m:GetOrderResponse": {
    "@xmlns:m": "urn:shop",
    "m:Order": {
      "@id": "A1",
      "m:Line": { "@sku": "BK-42", "#text": 2 }
    }
  }
}

Strip prefixes, fix lists and choose key case

Open More options and turn on Strip namespaces to remove prefixes such as m: and the xmlns attributes. Elements from different namespaces that share a local name then share a key, which is rarely a problem inside one SOAP body.

An order with one line produces an object, but an order with two lines produces an array, which breaks code that loops over lines. Enter Line under Always-array elements. Set Key case to camelCase to match JavaScript naming.

{
  "getOrderResponse": {
    "order": {
      "@id": "A1",
      "line": [
        { "@sku": "BK-42", "#text": 2 }
      ]
    }
  }
}

Generate types or a schema from the response

Switch the output view to Types to generate TypeScript interfaces, Zod schemas, Go structs, Python classes, Java, Kotlin or Rust types from the converted JSON. Switch to XSD to infer an XML Schema from the response, including which elements repeat or are optional in the sample.

Both are inferred from one sample. Compare them with the service's WSDL or published schema before relying on them, because a single response cannot show every optional element or allowed value.

export interface LineItem {
  "@sku": string;
  "#text": number;
}

export interface Order {
  "@id": string;
  line: LineItem[];
}

Reference: W3C: SOAP Version 1.2 Part 1, Messaging Framework.