XML to JSON
Convert xml to json using the available input and format options.
About XML to JSON
Older services, bank exports and RSS feeds still speak XML, while most JavaScript code expects JSON. This converter helps when you want to see the shape of an XML payload as an object, write a quick mapping, or build test fixtures for a front-end that consumes the converted data.
How it works
The browser's DOMParser reads your XML as text/xml. If the parser reports an error, you get an Invalid XML message. The root element becomes the top-level object, and its tag name is not included. Attributes become keys prefixed with @. Child elements become keys named after their tags, and a tag that repeats turns into an array. Text content is stored under a #text key. Every value stays a string. Comments appear as empty #comment objects, and CDATA content is not carried over.
How to use XML to JSON
- Enter the text or data in the format shown in the text box above (Paste XML).
- Select “Run tool” and check the result before copying or downloading it.
Worked example
Input: <book id="7"><title>Dune</title><tag>sci-fi</tag><tag>classic</tag></book>. Output: an object with "@id": "7", then "title": {"#text": "Dune"}, then "tag" as an array of two objects, {"#text": "sci-fi"} and {"#text": "classic"}. The word book does not appear, and the 7 stays a string rather than a number.
Tips for a better result
- Because the root tag name is dropped, note it separately if your code needs it, or wrap the document in a temporary outer element first.
- A tag that appears once is an object, but twice becomes an array. Code that reads the output should handle both shapes.
- Replace CDATA blocks with escaped text before converting, because CDATA content becomes an empty object in the output.
Frequently asked questions
Why is every number in quotes?
The converter copies attribute values and text exactly as strings and never guesses types. Convert numbers and booleans in your own code, where you know which fields should be numeric.
What happens with namespaces like soap:Envelope?
Prefixed names are kept as written, so keys look like "soap:Body". Namespace declarations show up as attributes such as "@xmlns:soap". Nothing is resolved or stripped.
Does it upload my XML anywhere?
No. Parsing uses the DOMParser built into your browser, and the JSON is produced on the page. The result can be saved as from-xml.json.
What to check
A formatted or parsed result is not proof that code is secure, correct or production-ready. Never paste production secrets.
Read the Privacy Policy for information about local processing, connected services and advertising.