XML ⇔ JSON Converter
Paste XML to convert it to JSON, or paste JSON to convert it to XML — handy for XML API responses, RSS feeds, and config files. To further format or validate the JSON, try the JSON Formatter as well.
🔒 Runs in your browser · Your data is never sent to a server
Notes
- Attributes are keys prefixed with "@_" (e.g. "@_id"), and text inside an element that also has attributes uses the "#text" key. The same notation is used for JSON→XML.
- Repeated child elements with the same name become an array, but a single one does not, so the shape of the result can change when the number of elements varies.
- XML comments, processing instructions, and the XML declaration are lost. JSON→XML does not add an XML declaration.
- If the JSON root has several keys or is an array, a <root> element is added.
- By default all values stay strings (to keep leading zeros such as in postal codes). Check the box to convert numbers and true/false to JSON types.
Glossary
XML
A data format that represents structure with nested tags. It is used for RSS, SOAP, Android layouts, and many config files.
JSON
Short for JavaScript Object Notation, a text format for representing data as key-value pairs. It is widely used for APIs.
Attribute
Extra information written inside a start tag, like id="1" in <user id="1">. JSON has no equivalent, so this tool represents attributes as keys prefixed with "@_".
FAQ
How are XML attributes represented in JSON?
Attributes become keys prefixed with "@_" (for example "@_id"), and text inside the same element becomes the "#text" key. JSON→XML reads the same notation, so you can round-trip the structure.
Why does the result change shape when an element appears once or several times?
XML has no array type, so only repeated elements with the same name become an array. A single element stays a single value, so when the number of elements can vary, handle both an array and a single value on the receiving side.
Why are my numbers strings?
By default every value stays a string so leading zeros such as in postal codes are not lost. Check "Convert numbers and true/false to JSON types" to get numbers and booleans.
Are XML comments and the XML declaration kept?
No. Comments, processing instructions, and the XML declaration are dropped during conversion. JSON→XML does not add a declaration either, so add one by hand if you need it.
Share this page
