Convert JSON to XML or XML to JSON while preserving attributes, text content, and nesting. Essential when working with legacy SOAP APIs, RSS/Atom feeds, or migrating data between modern and legacy systems.
Converted output will appear here
XML preceded JSON as the dominant data-interchange format on the web, and despite JSON's takeover for new APIs, XML remains everywhere in legacy systems. Anyone working at the boundary between modern and legacy stacks needs a way to convert between the two.
Common reasons to convert:
XML and JSON have different data models. XML elements can have both attributes (metadata on the element) and text content, plus child elements. JSON only has keys and values. To preserve information, our converter uses a convention:
@. <book id="123"> becomes {"@id": "123"}.#text.This convention is the de facto standard used by libraries like xml-js, fast-xml-parser, and Underscore's XML helpers. It survives round-trips cleanly: XML → JSON → XML produces a structurally equivalent document.
@. So <user id="42" role="admin">Alice</user> becomes {"user": {"@id": "42", "@role": "admin", "#text": "Alice"}}. This is the de facto convention used by most XML-to-JSON libraries.<ns:tag> becomes a JSON key "ns:tag"). Full namespace resolution with xmlns declarations is not performed — the converter treats prefixes as opaque strings.@xmlns:soap attributes. You may need to manipulate the resulting JSON to feed it into a modern API.<!-- ... -->) are stripped during conversion to JSON since JSON has no comment representation. Going back from JSON to XML, comments aren't reconstructed.<?xml version="1.0"?>) is preserved on output but not represented in the JSON. DOCTYPE declarations are stripped — JSON has no equivalent.xq (XML + jq).