XML to JSON Converter
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.
At a glance
- Converts XML to JSON and JSON to XML, instantly 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 your browser: the data you paste or open is never uploaded.
Step by step
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.
Features
Everything you need, nothing you don’t
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.
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
Frequently asked questions
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
JSON to XML Converter
Convert JSON to XML online: attributes, text, arrays and nested data, with a root element, CDATA and pretty or minified output. Free and private, no upload.
JSON Formatter & Validator
Format, validate, minify and repair JSON online. Get the exact line and column of every error, a collapsible tree view and sorted keys — private, in-browser.
JSON to CSV Converter
Convert JSON to CSV for Excel or Google Sheets: nested objects become columns, lists are kept and big numbers stay exact. Also CSV to JSON. No upload.
CSV to JSON Converter
Convert CSV or data pasted from Excel to JSON: auto-detected delimiter, real numbers and true/false, nested objects from dotted columns. Free, no upload.
DNS Lookup
Free DNS lookup: check A, AAAA, CNAME, MX, NS, TXT, SOA and CAA records of any domain, see SPF and DMARC, and do reverse DNS for an IP address.
DNS Propagation Checker
Check DNS propagation worldwide: see the A, CNAME, MX, NS or TXT answer from 7 public DNS networks and 18 ISPs in 15 countries, and track the change.
Last updated Report a problem or suggest a feature