# XML to JSON

`xml-to-json` · version 1.0.0 · YAML, TOML, INI, XML & TSV · free, no key needed

Convert an XML string to a JSON object.

**Use when you need to: xml to json · parse xml · convert xml to json.**

## Supported

- xml to json
- parse xml
- convert xml to json

## Not supported

- json to xml
- read files
- fetch urls
- execute xml external entities (XXE)

## Behavior

- Parses XML into JSON.
- Attributes are included as properties with a "@_" prefix by default.
- Does not expand external or internal entities for security reasons.
- Values remain as strings (no implicit type coercion to numbers or booleans).
- Mixed content (text mixed with elements) is unsupported and explicitly rejected.
- Validates well-formedness before parsing.

## Input

- `xml` (string, required): max length 262144

## Output

- object

## Limits

- max input bytes: 262144

## Example

Request input:

```json
{
  "xml": "<person><name>Ada</name><city>London</city></person>"
}
```

Response:

```json
{
  "result": {
    "person": {
      "name": "Ada",
      "city": "London"
    }
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "xml-to-json",
  "version": "1.0.0",
  "input": {
    "xml": "<person><name>Ada</name><city>London</city></person>"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/xml-to-json/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"xml":"<person><name>Ada</name><city>London</city></person>"}'
```

The machine-readable contract is at [/v1/tools/xml-to-json/versions/1.0.0](/v1/tools/xml-to-json/versions/1.0.0).

### CLI

```sh
node cli.mjs run xml-to-json 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [INI to JSON](/tools/ini-to-json): Convert an INI string to a JSON object.
- [JSON to XML](/tools/json-to-xml): Convert JSON data to an XML string.
- [TOML to JSON](/tools/toml-to-json): Convert a TOML string to a JSON object.
- [TSV to JSON](/tools/tsv-to-json): Convert a complete TSV document into an array of string-valued objects.
- [YAML to JSON](/tools/yaml-to-json): Convert a YAML string to a JSON object or array.
- [JSON to INI](/tools/json-to-ini): Convert JSON data to an INI string.
