Markdown & Convert
XML ↔ JSON Converter
Convert between XML and JSON - attributes preserved with @-prefix.
Direction
XML input
JSON output
About this tool
Convert XML to JSON or JSON to XML. XML attributes become @-prefixed keys (e.g. <a href="x"> → {"a": {"@href": "x"}}). Text content uses the #text key. Repeated child tags become arrays. Useful when bridging XML APIs (SOAP, RSS, Atom) with JSON-only tooling.
FAQs
How are XML attributes represented in JSON?
By default, attribute names are prefixed with '@' to distinguish them from child elements. <user id="1"><name>A</name></user> becomes {"user":{"@id":"1","name":"A"}}.
Is the conversion lossless?
Mostly. XML namespaces, processing instructions, and comments are dropped. Element order is preserved when children have unique tag names; repeated tags collapse into an array.
Does it validate against a DTD or schema?
No - the tool only handles syntactic conversion. Use a separate validator (xmllint, ajv for JSON Schema) if you need schema enforcement.
Can it handle large files?
Parsing happens in-memory using the browser's DOMParser. Multi-megabyte files work; gigabyte feeds won't fit. For very large inputs, use a streaming converter server-side (xml-stream, oxidized json2xml).
What about CDATA sections?
CDATA contents are preserved as plain text in the resulting JSON. On the reverse trip they're emitted as regular escaped text, not re-wrapped in <![CDATA[…]]>.