# XML to JSON

> Convert XML elements and attributes into JSON.

[Open tool](https://www.toolcabana.com/rm/xml-to-json) · [Developer and data](https://www.toolcabana.com/rm/category/developer-and-data)

Tool ID: xml-to-json. Requested language: rm. Description language: en. Complete guide translation: no; untranslated sections use English.

## Overview (en)

XML to JSON converts well-formed XML into formatted JSON that keeps both elements and attributes. Attributes appear as keys prefixed with @_, repeated sibling elements become arrays, and element text that looks like a number is converted to a number. Invalid XML is reported with a line number, and DOCTYPE or entity declarations are refused.

## Supported tasks (en)

Convert XML elements and attributes into JSON.

## Steps (en)

1. Paste the source into the input editor, or load the built-in example.
2. Check the source format before running the operation.
3. Run xml to json, review the output, then use the available copy or download controls.

## Settings

No additional settings.

## Limitations (en)

Text operations generally accept up to 2,000,000 characters. Individual parsers, generators and formulas apply additional limits shown by their controls.

## Example input

```text
<root><name>ToolCabana</name><count>2</count></root>
```

## Privacy and connections (en)

This operation processes its source in your browser. Copy and download are explicit actions; source input is not saved in an account or history.

## Questions (en)

### How are XML attributes shown in JSON?

Attributes are kept and appear on their element object as keys starting with @_, so id="1" becomes "@_id": "1". Attribute values stay strings.

### What happens to repeated XML elements when converting to JSON?

Sibling elements with the same name are grouped into a JSON array under that name. A single occurrence stays a plain value or object.

### Why did XML to JSON remove leading zeros?

Element text that looks like a number is parsed as a JSON number, so a value such as 007 becomes 7. Keep codes as attributes if their exact text matters.

### Where is my input processed?

This operation processes its source in your browser. Copy and download are explicit actions; source input is not saved in an account or history.

### What are the input limits?

Text operations generally accept up to 2,000,000 characters. Individual parsers, generators and formulas apply additional limits shown by their controls.

## Related tools

- [YAML to JSON](https://www.toolcabana.com/rm/yaml-to-json)
- [JSON to YAML](https://www.toolcabana.com/rm/json-to-yaml)
- [CSV to JSON](https://www.toolcabana.com/rm/csv-to-json)
- [JSON to CSV](https://www.toolcabana.com/rm/json-to-csv)
