XML to JSON

Attributes become @key properties. Element text becomes #text. Repeated elements become arrays.

Runs in your browser. Nothing is uploaded.
XML in
JSON out

JSONYard's online XML to JSON converter parses XML and emits JSON using the conventional `@key` for attributes, `#text` for element text, and arrays for repeated sibling elements. It runs entirely in your browser.

XML and JSON model data differently — see JSON vs YAML vs XML for the tradeoffs that matter.

How elements are mapped

  • An element with only text becomes a string (or number/boolean/null if type-inferable).
  • An element with attributes <a x="1">hi</a> becomes { "@x": 1, "#text": "hi" }.
  • Two elements with the same name under a parent are folded into an array.
  • The root element is preserved as the top-level key.

When you need XML converted to JSON

Modern web clients prefer JSON because it deserialises straight into JavaScript objects. If you're talking to a legacy SOAP service, an Atom/RSS feed, or any system that emits XML, converting to JSON gives you something easier to query with the JSONPath tester, validate with a JSON Schema, or pretty-print with the JSON formatter.

FAQ

Are namespaces preserved?
Element names include their prefix, e.g. ns:foo. We don't expand them to URLs.
What about CDATA and comments?
CDATA content is included as text. Comments are dropped.
How do I convert XML to JSON online without uploading the file?
Paste the XML into the left pane — parsing happens locally in your browser via the native DOMParser. Nothing is sent to a server.

Related conversion tools