XML ⇄ JSON Converter

Converts XML documents to JSON and back, using a standard convention for attributes, text content, and repeated elements. Nothing leaves your browser.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
XML input
0 lines · 0 charsXML
JSON output
Ctrl/Cmd+Shift+C
0 charsJSON

About This Tool

XML is still the native format for SOAP APIs, RSS/Atom feeds, legacy enterprise systems, and many config formats, but most modern tooling speaks JSON. This converter walks an XML document and maps it to JSON using the convention most XML-to-JSON libraries share: element tag names become object keys, attributes nest under a "@attributes" key, text content nests under "#text" when the element also carries attributes or children, and repeated sibling elements with the same tag name become an array.

JSON → XML runs the same convention in reverse, so a round trip through this page reproduces the original shape. For arbitrary JSON with no matching XML convention in mind, rendering as a Markdown list or table is often clearer, see JSON to Markdown.

Key Features

  • Bidirectional: one Direction dropdown (or the ⇌ swap button) switches between XML → JSON and JSON → XML.
  • Standard attribute/text convention - "@attributes" and "#text" keys, matching common XML-to-JSON libraries.
  • Repeated elements become arrays: sibling elements sharing a tag name collapse into a JSON array automatically.
  • Entity & CDATA aware: decodes &amp;/&lt;/&#NN; and reads <![CDATA[...]]> sections as literal text.
  • Configurable root tag: set the root element name used when converting JSON back to XML.
  • Clear parse errors: malformed XML (mismatched tags, unclosed elements) is reported with a specific message instead of failing silently.

Example

<person id="1">
  <name>Ada</name>
  <tag>admin</tag>
  <tag>dev</tag>
</person>

produces:

{
  "person": {
    "@attributes": { "id": "1" },
    "name": "Ada",
    "tag": ["admin", "dev"]
  }
}

FAQ

Why do my array values and numbers come out as strings?
XML has no native type system; every attribute value and text node is a string. This tool doesn't guess types, so numbers, booleans, and arrays of scalars all stay as strings to avoid silently changing your data.
What happens to XML comments and the <?xml?> declaration?
Both are parsed and skipped; they don't appear in the JSON output. CDATA sections are kept, as literal text.
How does JSON → XML handle a JSON array at the root?
Since a well-formed XML document needs exactly one root element, a root-level array is wrapped as repeated <item> children under the root tag you set.
What if my XML has a syntax error?
Conversion stops and the input panel shows a specific error (a mismatched closing tag, an unclosed element, or content after the root) rather than partial or guessed output.