XML to JSON Converter
Data ToolsPaste XML and get JSON, with attribute and array rules you can see and change.
Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy
About
What the XML to JSON Converter does
The XML to JSON Converter turns an XML document into JSON. Attributes become @name keys and element text becomes #text when an element also has attributes. Element names that repeat anywhere in the document become arrays everywhere, so their shape is predictable. Numbers and booleans can become JSON types. DTDs and external entities are never loaded, so the converter is safe for untrusted XML.
Steps
How to use it
- 1Paste XML or upload an .xml, .rss or .atom file.
- 2Choose the attribute, array and value rules.
- 3Press Convert, then copy or download the JSON.
Example
A real run
Input
<item> <title>Node.js 24 released</title> <link>https://example.com/node-24</link> <pubDate>Tue, 25 Nov 2026 09:00:00 GMT</pubDate> <category>javascript</category> <category>release</category> <guid isPermaLink="false">a1b2c3</guid> </item>
Output
{
"item": {
"title": "Node.js 24 released",
"link": "https://example.com/node-24",
"pubDate": "Tue, 25 Nov 2026 09:00:00 GMT",
"category": [
"javascript",
"release"
],
"guid": {
"#text": "a1b2c3",
"@isPermaLink": false
}
}
}The two category elements become an array; guid keeps its attribute as @isPermaLink, with the text under #text, and false becomes a JSON boolean.
Options
Every setting, and when to use it
- Attributes as @name
- On, <guid isPermaLink="false">a1</guid> becomes {"@isPermaLink": false, "#text": "a1"}. Off, attributes are dropped for a simpler shape when you only need element text.
- Repeated elements always arrays
- On, any element name that occurs more than once under some parent becomes an array everywhere, so code can always loop over it. Off, a single element is an object and several are an array, which is shorter but less predictable.
- Numbers and booleans as JSON types
- On, <qty>2</qty> becomes 2 and true stays true. Off, every value stays a string, which is safer for ZIP codes, phone numbers and IDs with leading zeros.
Good to know
Common problems and limits
Input up to 5 MB. A DOCTYPE is ignored: external DTDs and the entities they declare are never loaded or expanded, which protects against XXE and entity-expansion attacks.
Namespace prefixes are kept in key names, such as atom:link, and comments and processing instructions are dropped.
Invalid XML shows the line and column of the first problem. To tidy the XML first, use the XML Formatter; to go back, use JSON to XML.
Audience
Who uses it
- Integration developersTurn SOAP responses, RSS and Atom feeds or partner XML exports into JSON that JavaScript and most APIs work with.
- Data teamsConvert XML exports from ERPs, sitemaps or government data portals into JSON for analysis.
- DevelopersInspect an unfamiliar XML payload as JSON to see its structure at a glance.
FAQ
Frequently asked
How are XML attributes represented in JSON?
As keys with an @ prefix next to the child elements: <order id="A-1001"> gives {"@id": "A-1001", …}. When an element has attributes and text, the text goes under #text. Turn attributes off to drop them.
Why is a single element sometimes not an array?
XML does not say whether an element can repeat. With Repeated elements always arrays on, any name that repeats somewhere in the document is an array everywhere, including where it appears once. A name that never repeats in this document stays an object.
How do I convert a SOAP response to JSON?
Paste the whole envelope; namespace prefixes such as soap:Envelope are kept as key names, so the data is under soap:Envelope, then soap:Body. Copy the part inside the body if you only need the payload.
Is it safe to convert XML from an unknown source?
Yes. External entities and DTDs are never loaded and entity declarations are not expanded, so XXE file reads and billion-laughs expansion cannot happen. Conversion runs in your browser, not on a server.
How do I convert XML to JSON in Python or JavaScript?
In Python, xmltodict.parse(xml) gives the same @ and #text shape as this page. In JavaScript, the fast-xml-parser library, which this page uses, does it with new XMLParser({ignoreAttributes: false, attributeNamePrefix: "@"}).parse(xml).
Is my XML sent anywhere?
No. It is parsed in your browser. A copy of each conversion is saved to your past runs so you can reopen it.
Automation: an MCP tool xml_to_json(xml, options) → json and an n8n node are planned for this tool.