What Is XML to JSON Conversion?
XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are both widely used data interchange formats. XML uses a tag-based hierarchical structure, while JSON uses key-value pairs and arrays. Converting between the two is a common task when integrating systems that speak different data formats, migrating legacy APIs, or transforming configuration files.
This tool handles nested elements, attributes, text content, arrays of repeated elements, and mixed content. It produces clean, well-formatted JSON output that you can use directly in your applications, APIs, or data pipelines.
How It Works
Paste your XML into the input area and click "Convert to JSON." The tool sends your XML to the ToolPipe API endpoint POST /api/xml/to-json, which parses the XML tree and maps it to a JSON structure. Element attributes are typically prefixed with @, and text content is stored under a #text key when mixed with child elements.
API Access
curl -X POST https://toolpipe.com/api/xml/to-json \
-H "Content-Type: application/json" \
-d '{"xml": "<root><item>hello</item></root>"}'
Frequently Asked Questions
Does this tool preserve XML attributes?
Yes. Attributes are converted to JSON keys, typically prefixed with @ to distinguish them from child elements. For example, <user id="1"> becomes {"@id": "1"}.
How are repeated XML elements handled?
When an XML element appears more than once under the same parent, those elements are automatically grouped into a JSON array. A single element remains as an object.
Can I convert JSON back to XML?
Yes. Check out our JSON to XML Converter for the reverse operation.
Related Tools
JSON to XML | JSON Formatter | XML Formatter | JSON to YAML | CSV to JSON