XML to JSON

Turn XML into JSON, keeping attributes (as @attr), handling CDATA and typing values.

Pay by wallet (x402) xml-to-json

Example

Example answer
{
  "json": "test",
  "root_element": "root",
  "element_count": 0,
  "attributes_preserved": false
}

Inputs

FieldTypeRequiredWhat it is
xml_stringstringYes—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
jsonobjectAlways (present in every successful answer)
root_elementstringAlways (present in every successful answer)
element_countintegerAlways (present in every successful answer)
attributes_preservedbooleanAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "xml-to-json",
    "inputs": {
      "xml_string": "<root><item>value</item><count>42</count></root>"
    },
    "max_price_cents": 3
  }'

Limitations

  • Mixed content can lose its text ordering

    Converts standard XML — XML with mixed content (text interleaved with elements) may lose text ordering during conversion

    What to do instead: For mixed-content XML, use a streaming parser that preserves text node positions