JSON ↔ XML Converter
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
When you need JSON ↔ XML conversion
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:
- SOAP web services still power many enterprise systems (banking, government, healthcare). SOAP envelopes are XML. To integrate with a modern app that prefers JSON, you convert at the boundary.
- RSS and Atom feeds are XML by spec. To process them with JSON-based tools (most modern data pipelines), convert first.
- Office Open XML formats (.docx, .xlsx) use XML internally. Tools that introspect Word or Excel files often work with the XML directly.
- Configuration files in older Java/.NET projects often use XML. Migrating to modern JSON-based tooling means a one-time conversion.
- EDI and HL7 healthcare data, banking ISO 20022 messages, and other industry standards still use XML. JSON conversion makes them easier to process in modern stacks.
How attributes and text are preserved
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:
- XML attributes become JSON keys prefixed with
@.<book id="123">becomes{"@id": "123"}. - Element text content (when an element has both attributes and text) becomes a key called
#text. - Pure text elements (no attributes, no children) become a simple string value.
- Repeated elements become arrays in JSON.
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.
FAQ — Json To Xml
@. 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).Where to go next
- JSON ↔ YAML — a closer structural match than XML
- JSON → CSV — if the data is really tabular
- Formatter — check the JSON parses before converting