About this tool
Convert XML from feeds, SOAP services and config files into JSON. Attributes get a prefix, @_ by default, and text that sits next to attributes goes under #text, so nothing collides. Values stay as written unless you turn on type detection, and documents that declare custom entities are refused, which blocks the usual XML attacks.
How to use it
- Paste XML or import a file.
- Set the attribute prefix, text key and array behaviour.
- Review the warnings, then copy or download the JSON.
Example
<book id="bk101"> <title>Clean Code</title> <price currency="USD">8.99</price> </book>
{
"book": {
"title": "Clean Code",
"price": {
"#text": "8.99",
"@_currency": "USD"
},
"@_id": "bk101"
}
}Questions
- Why is one element an object and another an array?
- XML doesn't say whether an element can repeat, so one <book> becomes an object and two become an array. Turn on "Always use arrays" if your code needs the same shape every time.
- Are numbers converted?
- Not by default, because XML has no types and values like 007 would be damaged. "Detect types" converts numbers and booleans only when they convert back to exactly the same text.
- Is it safe for untrusted XML?
- Yes. Documents that declare their own entities are refused, which blocks “billion laughs” and external entity attacks, and nothing is ever fetched from the network.