Paste XML or open a file and get JSON as you type. Choose how attributes, text, repeated elements and namespaces are written. Nothing is uploaded.
How it works
Open or paste XML
Drop an .xml or .xml.gz file, use Open file or Open from URL, paste the markup or load the sample.
Choose the JSON shape
Pick the attribute prefix, the text key, whether repeated elements are always arrays, and whether numbers and true/false become JSON types.
Download or copy
The JSON updates on every change. Download the .json file, copy it, or open it in the JSON Viewer.
Features
Attributes and text nodes
Attributes become keys with a prefix of your choice: @id, @_id, -id or no prefix. Text next to attributes or child elements is stored under #text, or another key you set.
Predictable arrays
Repeated elements become arrays. Turn on Always arrays to make every child element an array, so your code does not break when an element occurs only once.
Namespaces and CDATA
Keep prefixes such as ns:item or remove them together with xmlns attributes. CDATA sections are merged into the text or kept under #cdata.
Clear errors
XML that is not well-formed is reported with line and column, and Go to error jumps to the problem. Elements that mix text and child elements are listed as a warning, because JSON cannot keep their order.
Safe with untrusted files
Our own XML parser never loads external entities (XXE) and limits entity expansion, so "billion laughs" files fail fast instead of hanging the page.
Round trip
The JSON → XML button opens the result in the reverse converter; simple documents convert back to the same XML.
Limits & privacy
Files can be up to 100 MB, also after decompressing an .xml.gz file. Files above 5 MB are converted from the file without loading them into the editor; only the beginning is shown.
DTD and XSD validation are not performed, and external DTDs or entities are never fetched. Comments and processing instructions are not included in the JSON. See the privacy page.
FAQ
How do I convert XML to JSON online?
Paste the XML or open the file. The JSON appears on the right immediately; press Download .JSON to save it or Copy to put it on the clipboard.
How are XML attributes converted to JSON?
Each attribute becomes a key with a prefix, by default @, so <book id="1"> becomes {"book": {"@id": "1"}}. You can switch to @_, - or no prefix.
Why is an element sometimes an array and sometimes an object?
An element that occurs once becomes an object, one that repeats becomes an array. Turn on Always arrays if your code needs the same structure for every document.
Are numbers converted to JSON numbers?
Only when you turn on Numbers and true/false. By default every value stays a string, because XML has no types and values like 007 would lose their leading zero.
Can I format the JSON output?
Yes. Choose 2 spaces, 4 spaces, tabs or a single line.
Is my XML uploaded to a server?
No. The conversion runs in a Web Worker in your browser and works offline once the page has loaded.