XML to JSON
Convert XML documents or snippets into JSON for APIs, scripts and modern data workflows.
Your result will appear here.
XML to JSON online
Convert XML into JSON with the browser's real XML parser — elements become keys, repeated elements become arrays, attributes are kept under @attributes.
How to use this tool
- Paste your XML into the input box.
- Click Run Tool. The document is parsed as genuine XML, so malformed markup is reported instead of guessed at.
- Copy the JSON from the result panel.
Common uses
Bringing RSS, sitemap and legacy API responses into JavaScript tooling, inspecting an XML payload's structure as JSON, and prototyping the mapping before writing a real importer.
How it works
The converter parses with the browser's DOMParser and then walks the tree: the root element becomes the top-level key, child elements become properties, and text-only elements become strings. When the same tag repeats among siblings, the values combine into an array — a single occurrence stays a plain value. Attributes are preserved under an @attributes object. All values remain strings: XML has no number or boolean types, so <age>30</age> arrives as "30".
Worked example
Paste:
<user id="7"><name>Ana</name><tag>a</tag><tag>b</tag></user>
and the result is:
{ "user": { "name": "Ana", "tag": ["a", "b"], "@attributes": { "id": "7" } } }One tag would have stayed a plain string — the array appears only because the tag repeats.
Privacy and browser processing
Your XML is parsed in your browser with JavaScript — it is never uploaded or stored.
Frequently asked questions
Why is a value sometimes an array and sometimes not?
Repetition drives it: a tag that appears once among its siblings maps to a single value, and a repeated tag maps to an array. Code consuming the output must handle both shapes, or normalise afterwards.
What happens to text mixed between child elements?
Text that sits alongside child elements is not represented — only pure text-only elements keep their text. Mixed content (common in document XML like XHTML) loses its loose text in conversion.
Does it keep namespaces?
Element names are carried over as written, prefix included. There is no namespace resolution or renaming.
Why did it say "Invalid XML"?
The document failed the browser's XML parser — unclosed tags, a raw & that should be &, or stray text outside the root are the usual causes. The strictness is a feature: broken XML is flagged, not repaired.
Is my XML uploaded?
No. Parsing runs in your browser; nothing is sent to a server.