XML to JSON
Paste an XML document and get a clean JSON representation. Attributes are prefixed with "@", text content uses "#text", and repeated sibling elements become arrays automatically. Runs in your browser.
Convert XML into a simple JSON representation in the browser. Attributes become keys prefixed with @, text mixed with other structure uses #text, and repeated child tags are grouped into arrays.
How to convert XML to JSON
- Paste valid XML into the input box.
- Leave Pretty JSON enabled for indented output or disable it for compact JSON.
- Click Convert.
- Review the generated object structure, including attributes and repeated tags.
- Copy the JSON when it matches your needs.
How XML nodes are mapped to JSON
Element attributes are written as keys such as @id. Child elements are grouped by tag name, and if the same tag appears more than once, its values are converted into an array in encounter order.
An element with only text becomes a string when it has no attributes. If an element has attributes or child elements plus text, the text is stored under #text. Comments are ignored, empty text-only elements can become null, and the document object is represented by its root element value rather than wrapping the root tag name itself.
Privacy and limitations
Conversion happens locally in the browser and the XML is not intentionally sent to a server for processing. XML-to-JSON has no single universal mapping standard, so this tool uses its own simple @attribute and #text conventions. Mixed-content documents, namespaces, ordering-sensitive XML, comments, and other XML-specific constructs may lose information or structure that another application expects.
Frequently asked questions
How are XML attributes represented?
Each attribute becomes a property whose name starts with @.
What happens when the same child tag repeats?
Repeated tags are collected into an array.
How is element text represented?
Plain text-only elements become strings; mixed structured elements use #text.
Are XML comments included?
No. Comment nodes are ignored by the conversion.
Is this mapping guaranteed to match another XML-to-JSON library?
No. XML-to-JSON conventions vary between tools and libraries.