XML to JSON Converter
Convert XML to JSON in your browser. Attributes, namespaces and mixed text are kept. Copy or download the JSON.
Loading tool…
How it works
Paste XML
Paste XML, open a file up to 5 MB, or drop one on the box. It is read in this tab and never uploaded.
Pick the options
List tags that should always be arrays. Turn on number conversion if you want 42 instead of "42".
Copy or download
Copy the JSON or download it as a .json file.
How is XML mapped to JSON?
Attributes become "@name" and text becomes "#text". XML names cannot start with @ or #, so these keys never clash with a child tag. Repeated tags become an array. An empty tag is null (<x/> and <x></x> are the same), a tag with only text is a string. Prefixes stay as written, like a:root, and xmlns attributes are kept.
What does JSON lose?
The order between text and tags, and between different tags (<x/><y/><x/>). Comments, processing instructions, the DOCTYPE and whitespace-only text are dropped, unless xml:space="preserve" keeps the whitespace. Default attribute values from the DOCTYPE are filled in. CDATA becomes plain text, entities are decoded, CRLF line ends become LF, and line breaks and tabs in attribute values become spaces. With number conversion on, 42 and "42" look the same.
Why is my XML rejected?
It must be well-formed: one root element, every tag closed. Besides & < > " ', named entities like need a declaration, and documents that declare entities are refused, because expanding them can freeze the tab. Use numeric references like   instead. External DTDs are not fetched.
Which values become numbers?
Only with the option on, and only when the whole value is a JSON number that reads back as the same text: 42, -3.5, 1.5e-7. So 007, 1.0, 1e3, -0 and integers past 2^53 - 1 (positive or negative) stay strings. Only true and false become booleans.
Need data from a website, not a file?
Browser Use agents open pages in a real browser, including dynamic ones, and return structured data.