Developer Tools
XML to JSON Converter
XML to JSON Converter is part of Toolspire and is ready as soon as this page loads. Turn XML into clean JSON — or JSON back into XML — as you type. Attributes, repeated elements and IDs with leading zeros are handled correctly, and errors point to the exact line.
On this page
What you can do here
Both directions
XML → JSON and JSON → XML in one tool. Switching direction carries the result across, so you can convert back and forth.
Safe numbers
Unlike many converters, it never turns “00482” into 482 or rounds a 20-digit ID. Only values that convert exactly become numbers.
Predictable arrays
Turn on Always use arrays so code that reads the JSON works the same for one item or a hundred.
Exact error locations
An unclosed tag or a missing comma is reported with its line and column, and one click jumps to it in the input.
Your naming
Choose the attribute prefix (@, _, -, $), rename the text key, drop namespace prefixes or ignore attributes entirely.
Private
Configs, API responses and feeds are converted on your device. Nothing is sent to a server.
The sequence
How to convert XML to JSON
- 1
Add your XML
Paste XML into the input, or click Open file to load an .xml, RSS or other XML file.
- 2
Adjust the options
Open Options to change the attribute prefix, keep every element as an array, or turn off number conversion.
- 3
Check the result
The JSON appears as you type. If the XML has an error, its line and column are shown.
- 4
Copy or download
Copy the JSON or download it as a file. Choose JSON → XML to convert in the other direction.
Worth knowing
- XML to JSON Converter on Toolspire: converts XML to JSON and JSON to XML, straight away as you type.
- Attributes become keys with a prefix (
@by default), text beside attributes goes into#text, and repeated elements become arrays — all configurable. - Numbers and booleans are converted safely: values with leading zeros (
007) or more than 15 significant digits stay as text, so IDs and codes are never changed. - Always use arrays keeps the JSON shape the same whether an element appears once or many times.
- Invalid XML or JSON is reported with the exact line and column. CDATA, entities and namespaces are supported.
- Copy the result or download it as a .json or .xml file.
- Runs in this tab: the data you paste or open is not sent to us.
How XML maps to JSON
| XML | JSON |
|---|---|
<name>Asha</name> | "name": "Asha" |
<user id="7"/> | "user": { "@id": 7 } |
<price currency="INR">799</price> | "price": { "@currency": "INR", "#text": 799 } |
<tag>a</tag><tag>b</tag> | "tag": ["a", "b"] |
<sku>00482</sku> | "sku": "00482" (leading zero kept) |
<empty/> | "empty": "" |
<![CDATA[<b>bold</b>]]> | "<b>bold</b>" |
How JSON becomes XML
- Keys that start with the attribute prefix (
@id) become attributes; the#textkey becomes the element’s text. - Arrays repeat the element:
"item": [1, 2]becomes<item>1</item><item>2</item>. nulland empty strings become empty elements like<notes/>.- XML needs one root element, so data with several top-level keys, or a top-level array, is wrapped in
<root>. - Keys that aren’t valid XML names are made valid:
"first name"becomes<first_name>,"2nd"becomes<_2nd>. - Numbers are written exactly as they appear in the JSON, and
&,<and>are escaped.
FAQ
Questions about XML to JSON Converter
Where does XML to JSON Converter run?
Is it safe to convert confidential XML here?
Why are some numbers kept in quotes?
00482 or 20-digit IDs would change if turned into JSON numbers, so they stay as text. Turn off Convert numbers & booleans to keep every value as text.Why is a single element not an array?
What happens to attributes?
@id by default — placed before the element’s children. You can choose _, - or $ instead, or ignore attributes.Are XML comments kept?
<?xml ?> declaration are dropped. CDATA content is kept as text.Can I convert JSON to XML?
@ become attributes and arrays become repeated elements, so XML converted to JSON here converts back to the same XML.Does it work with RSS, SOAP and sitemap files?
Keep going
Related tools
Last updated Report a problem or suggest a feature