Runs on your device · Your file never leaves your device.
Drop an .xml file or paste XML from an API, a feed or a configuration file and get JSON you can work with. The document is read by the browser’s own XML parser, in the encoding its first line declares, so anything that is well-formed converts, and a malformed file is reported with the line and column of the problem and what is wrong there.
The mapping is fixed and reversible: each element becomes a key; siblings with the same name become an array; attributes are kept under keys starting with @ (id="A3" becomes "@id": "A3"); and when an element holds both text and children or attributes, the text goes under "#text". An element with only text becomes the value itself.
With type detection on, text such as 12, true or an empty element becomes a number, a boolean or null; switch it off to keep everything as text. Namespaced names (soap:Body) are kept as written. The preview shows the first 200 lines before you download.
Not for: Documents that are not well-formed XML (unclosed tags, HTML pages) — the parser reports the first problem rather than guessing.
Type detection applies to attributes as well as to text, and changes a value only where nothing is lost. With it on, id="3" becomes "@id": 3, while id="007" stays the text "007". 1.50 also stays text, because as a number it would be written back as 1.5. TRUE becomes true. An empty element such as <note/>, and one holding only spaces, become null; the word NULL stays text. Dates such as 2024-01-05 are never converted.
With detection off, empty elements become "" and every value stays text exactly as written.
Some parts of an XML document have no place in JSON and are dropped: comments, processing instructions and the DOCTYPE. CDATA sections become ordinary text, so <a><![CDATA[<b>x</b>]]></a> gives "a": "<b>x</b>".
Order between elements with different names is lost, because each name becomes one key. In <step>1</step><note/><step>2</step>, both steps are gathered into "step": [1, 2], and nothing records that the note sat between them. Text mixed with markup loses its place in the same way: <p>Hello <b>world</b> and <i>you</i>!</p> becomes "b": "world", "i": "you" and "#text": "Hello and !". For documents where that order is the content, such as formatted prose, this mapping is not a good fit.
Prefixed names are kept as written, and namespace declarations appear as attributes: <soap:Envelope xmlns:soap="…"> gives a key "soap:Envelope" holding "@xmlns:soap", and /json-to-xml turns both back into the same XML.
Apart from entities that the document's own DOCTYPE defines, only the five built into XML (& < > " ') and numeric ones such as   are understood. When the parser stops, the message gives the line and column and says what is wrong in plain words: an element closed with another name, an unknown name such as (write   instead), a bare & or <, a second top-level element, or a file that ends too early.
The file is read in the encoding its first line declares, such as ISO-8859-1 or windows-1256. Without a declaration, UTF-8 or UTF-16 is read, and older code pages are recognised as described on /csv-to-json.
This page in other languages: العربية · Deutsch · Français · Español · Русский · Português · 中文 · हिन्दी · Türkçe · עברית · فارسی · اردو · Bahasa Indonesia · বাংলা