XML ↔ JSON Converter

Convert between XML and JSON online — runs in your browser

XML to JSON Conversion

XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are both widely used data formats. Converting between them is a common task when working with legacy systems, SOAP APIs, RSS/Atom feeds, configuration files, and modern REST APIs.

When to convert XML→JSON

When consuming a legacy SOAP API in a JavaScript application, when processing RSS/Atom feeds, or when working with XML configuration files in a JSON-native environment.

When to convert JSON→XML

When sending data to a SOAP web service, when your system requires XML for storage or messaging (e.g. XMPP, FHIR health data), or when generating XML-based documents.

Attributes handling

XML attributes are converted to an @attributes object in the JSON output. This preserves all attribute data while keeping the structure navigable.

Arrays from repeated elements

Repeated XML elements with the same tag name are automatically converted to JSON arrays. Unique tags become single values.

Frequently Asked Questions

Is there a lossless way to convert XML to JSON?
Not perfectly. XML supports concepts (attributes, processing instructions, namespaces, mixed content) that have no direct JSON equivalent. This tool preserves attributes in an @attributes object and text content in #text, which captures the most common cases. Complex XML with mixed content may require custom handling.
Why do repeated XML elements become arrays?
JSON arrays represent ordered, repeated elements — which is the correct semantic for repeated XML sibling elements with the same tag name. This matches how most XML-consuming libraries behave.
Does the tool handle XML namespaces?
Namespace prefixes are preserved in key names (e.g. ns:element). Namespace declarations (xmlns) are captured as attributes. Full namespace resolution is not performed.

Popular searches: xml to json converter • json to xml • xml parser online • convert xml to json free • xml formatter • xml json tool • parse xml online