XML to JSON
Convert an XML document or API response into JSON you can work with.
Runs in your browser — nothing you type is sent anywhere
JSON
The result appears here as you type. Nothing is sent anywhere — the work happens in this page.
Attributes become keys prefixed with @_, and an element’s text becomes #text when it also has attributes or children. Repeated sibling elements become an array — but a single element cannot be told apart from a one-item list without a schema, so it stays a plain value.
About the XML to JSON
Plenty of systems still speak XML — SOAP services, RSS feeds, sitemaps, government APIs, older enterprise software — and almost everything you would write to consume them prefers JSON. This converts one to the other in your browser.
The conversion is not entirely mechanical, because XML can express things JSON cannot, and the choices a converter makes determine whether the output is usable. Attributes become keys prefixed with <code>@_</code>. An element that has text as well as attributes or children gets its text under <code>#text</code>. Repeated sibling elements become an array. Those are the fast-xml-parser conventions, chosen because they are the ones most people have already seen.
One ambiguity has no good answer and is worth knowing about. A list with two items becomes an array; a list with one item cannot be told apart from a plain value, so it becomes one. Any code consuming the result should handle both — this is inherent to XML, not a shortcoming of the converter.
Numbers and true/false are converted where it is unambiguous, and deliberately not where it is risky: a value with a leading zero stays a string, because a postcode, part number or phone number turned into a number has been corrupted. That is a far more damaging mistake than a number arriving as a string, and it can be turned off entirely.
Entities are decoded, CDATA is taken literally, comments and the declaration are dropped, and a malformed document is reported with the tag that is wrong rather than producing half-converted output. It all runs in your browser.
How to use the XML to JSON
Paste your XML
An API response, a feed, a configuration file or an export.
Choose how values are treated
Convert numbers and true/false, or keep everything as strings. Attributes can be dropped if only the structure matters.
Read the JSON
Attributes appear under @_ keys and mixed content under #text, so nothing from the original is silently lost.
Copy or download
Take it to the clipboard or save it as a .json file.
Frequently asked questions
Why do attributes have an @_ prefix?
Why is a single element not an array?
Why did my leading zeros survive?
What is #text for?
Is my XML uploaded?
You may also need
XML Formatter
Indent XML properly, and be told when a tag is closed in the wrong place.
JSON to CSV
Turn an array of JSON objects into a spreadsheet-ready CSV, nested fields included.
YAML to JSON
Convert YAML into JSON, with indentation errors reported by line.
JSON Viewer
Fold a big JSON document into something you can actually read — and copy paths out of it.