Formatter Validator Minifier JSON ↔ YAML JSON → CSV JSON ↔ XML JSON Diff Schema Validator JSONPath Tester JWT Decoder More Tools Blog FAQ
Bi-directional · Preserves attributes and structure

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.

Input JSON
Output XML
Converted output will appear here
When you need JSON ↔ XML conversion

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:

How attributes and text are preserved

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:

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.

Common questions

FAQ — Json To Xml

How are XML attributes converted to JSON?
Attributes become JSON keys prefixed with @. 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.
Are XML namespaces supported?
Basic namespace prefixes are preserved as part of element names (so <ns:tag> becomes a JSON key "ns:tag"). Full namespace resolution with xmlns declarations is not performed — the converter treats prefixes as opaque strings.
What happens to CDATA sections?
CDATA content is preserved as plain text in the JSON. When converting JSON back to XML, special characters in the text are properly escaped — but they won't be re-wrapped in CDATA sections unless you explicitly request it.
Does this handle SOAP envelopes?
Yes, structurally. SOAP's envelope/body/header nesting converts cleanly. The namespace declarations on the envelope are preserved as @xmlns:soap attributes. You may need to manipulate the resulting JSON to feed it into a modern API.
Can I convert XHTML or HTML?
XHTML (which is well-formed XML) converts fine. Plain HTML (which often isn't well-formed — unclosed tags, missing quotes) will fail XML parsing. For HTML-to-JSON, use a dedicated HTML parser like Cheerio or BeautifulSoup.
How are XML comments handled?
XML comments (<!-- ... -->) are stripped during conversion to JSON since JSON has no comment representation. Going back from JSON to XML, comments aren't reconstructed.
What about XML processing instructions and DOCTYPE?
The XML declaration (<?xml version="1.0"?>) is preserved on output but not represented in the JSON. DOCTYPE declarations are stripped — JSON has no equivalent.
Can I convert RSS or Atom feeds to JSON?
Yes, both convert cleanly. The result is structurally close to what dedicated RSS-to-JSON parsers produce, though the key names follow the @/# convention rather than the more opinionated keys some libraries use.
Will the JSON validate against an XML Schema?
Not directly — XML Schema (XSD) is XML-specific. But you can write a JSON Schema that mirrors your XSD's constraints, then validate the converted JSON against it using our JSON Schema Validator.
How big a document can I convert?
Up to about 10 MB on most browsers. XML parsing is slower than JSON parsing because the DOM tree is larger in memory. For larger documents, use a command-line tool like xq (XML + jq).
Our Network