XML to JSON Converter
Turn XML into JSON. Attributes, repeated elements and numbers are handled, and errors say what is wrong.
How to convert XML to JSON
Paste your XML
Paste or type it into the box, or press Try an example.
Choose the prefix
Attributes get the prefix you set, such as @id, so they stay apart from child elements.
Convert values
Tick the box to turn numbers and true or false into real JSON values instead of strings.
Copy or download
Use the JSON in your code.
Worked example
This is what XML to JSON Converter gives for its own sample values. Open the tool above and change anything to try your own.
XML
<?xml version="1.0"?> <library name="City Library"> <book id="1"><title>Dune</title><year>1965</year></book> <book id="2"><title>Neuromancer</title><year>1984</year></book> </library>
- Indentation
- 2 spaces
- Attribute prefix
- @
- Convert numbers and true/false
- Yes
JSON
{
"library": {
"@name": "City Library",
"book": [
{
"@id": "1",
"title": "Dune",
"year": 1965
},
{
"@id": "2",
"title": "Neuromancer",
"year": 1984
}
...About XML to JSON Converter
Turn XML into JSON. Attributes get a prefix, repeated elements become lists, and numbers and true or false values can be typed for you. Mismatched tags are reported with a clear message.
FAQs
How are attributes shown?
As keys that start with the attribute prefix, @ by default.
Why did a number stay a string?
Switch on the conversion option, or the value is not a plain number, for example it has a leading zero.
Can I check the XML without converting?
Use XML Validator.