Paste XML to get JSON with attributes as @keys and repeated tags as arrays, or turn JSON back into XML. The XML is checked first, and errors show the line and column.
✓ Valid XML, converted to JSON.
Converted in your browser; your data isn't uploaded. Nothing in the file is run, and external entities and links aren't fetched.
How to use it
Paste XML or open a file (.xml, .rss, .svg, .kml and similar).
Choose the attribute prefix, whether to read numbers and true/false as values, and the indent.
Copy the JSON or download it. ⇄ swaps the direction to turn JSON into XML.
Conversion rules
The root element becomes the one top-level key, and each child element a key inside its parent.
Attributes become @name keys; text next to attributes or children goes in #text.
CDATA sections become plain text, and &, © and other character references are decoded.
Comments and processing instructions are dropped, since JSON can't hold them; a note tells you when comments were removed. An empty element such as <gift/> becomes "".
Example
In the order loaded above, <order id="A-1042" date="2026-10-11"> becomes "order": { "@id": "A-1042", "@date": "2026-10-11", … }. The two <item> elements become an array of two objects, each with @sku, @qty and #text ("Gel pen", "A5 notebook"). <total currency="INR">185.00</total> keeps "185.00" as text, and the CDATA note becomes the plain string "Leave at the door & ring the bell".
Reading and writing XML uses the open-source fast-xml-parser (MIT licence). To tidy XML without converting it, use the XML formatter; for YAML, the YAML to JSON converter.
Frequently asked questions
Why is one <item> an object but two are an array?
XML doesn't say whether an element is a list, so the converter makes an array only when a tag repeats. If your code always expects an array, wrap a single object in one, or check for both shapes.
How are attributes and text shown in JSON?
Each attribute becomes a key starting with @ (pick _, - or @_ instead if your code expects that), listed first. When an element has attributes or child elements as well as text, its text goes in a "#text" key; an element with only text becomes a plain string.
Are numbers converted?
Not by default: XML values are text, so 185.00 and 007 stay "185.00" and "007". Tick "Read numbers and true/false" to get 185 and true. Even then, 007 and very long numbers stay text so no digits are lost.
Can it convert JSON to XML?
Yes: set From to JSON and To to XML. Keys starting with your attribute prefix become attributes, "#text" becomes the element's text, arrays become repeated elements, and data without one top-level key is wrapped in a root element you can name. Keys that aren't valid XML names, like "first name", become first_name.
Is it safe to paste XML from an unknown source?
Yes. The XML is read as text in your browser: external entities and DTD links are never fetched, nothing is uploaded, and entity expansion is limited so a small file can't blow up into gigabytes.