Skip to content
TR ToolRux

XML to JSON Converter

Convert XML to JSON and JSON to XML. Handles attributes, nested elements, and arrays.

JSON Indent:

Input XML

Converted output will appear here

📖 Learn More

Everything you need to know

XML and JSON — Legacy Meets Modern

XML was the king of data interchange for decades — SOAP APIs, configuration files, and enterprise systems. JSON took over for web APIs because it's simpler and lighter. But XML isn't going away — this converter bridges the gap between both formats.

How Attributes Are Handled

XML attributes are represented as JSON properties prefixed with @. So <book category="fiction"> becomes {"@category": "fiction"}. Element text content is stored as #text when the element also has attributes or child elements.

Arrays from Repeated Elements

When an XML element has multiple child elements with the same tag name, they're automatically grouped into a JSON array. A single child stays as a plain object. This follows the common convention for XML-to-JSON mapping.

JSON to XML

Going from JSON to XML? The converter produces well-formed XML with proper indentation. Properties starting with @ become XML attributes. Array items are rendered as repeated elements. You can customize the root tag name.

Related Tools

Need other format conversions? Try the CSV to JSON Converter, YAML to JSON Converter, or the JSON Formatter for formatting and validation.