XML to JSON Converter
Convert XML to JSON as you type: attributes as @keys, repeated elements as lists, numbers as numbers. Paste or drop a file; nothing is uploaded.
How it works
Paste or drop your XML
Paste XML into the box or drop a file. It is read in your browser; the format is detected if you are not sure which it is.
Check the JSON
The JSON appears beside it as you type. A mistake in the input is pointed out by line and column instead of producing half a file.
Copy or download
Copy the JSON or download it as a .json file. Swap turns it straight back.
XML to JSON converter online
XML to JSON as you type: paste the XML or open the file, and the JSON appears beside it. This XML to JSON converter follows the conventions developers expect - attributes as @keys, text next to them as #text, repeated elements as arrays - so XML to JSON with attributes round-trips.
To convert XML to JSON, drop an XML file, an RSS feed, a SOAP response or a config file. XML to JSON online in the browser, and an XML to JSON converter online free of limits, because the conversion never leaves your computer.
XML to JSON array: two or more elements with the same name become a JSON array. Numbers and true/false become JSON values, while IDs with leading zeros stay strings.
People also search for
- json to xml
- xml to yaml
- xml to csv
- json formatter
Why it matters
Round-trips cleanly
XML attributes become @keys, text next to them #text and repeated elements lists, and they go back to the same XML: the conventions xml2js and xmltodict use.
Types where they are clear
Plain numbers and true/false become JSON numbers and booleans. Leading zeros, long IDs and phone numbers stay text, so nothing is quietly changed.
Nothing uploaded
Config files, API responses and exports with keys in them stay on your computer: the conversion runs in this tab.
Questions
How are XML attributes shown in JSON?
As keys that start with @: <book id="7"> becomes {"book": {"@id": 7}}. Text beside attributes or child elements goes under #text. The prefix can be changed or removed.
What happens to repeated XML elements?
Two or more elements with the same name become a JSON list. A single one stays an object, which is how most XML-to-JSON converters behave; check the shape if your code expects a list every time.
Are XML comments kept?
No. JSON and YAML have nowhere to put them, so they are left out and the page says how many.
What about text mixed in between elements?
Text that sits between child elements, as in a paragraph with <b>bold</b> words in it, is joined into one #text value. That suits data files; for documents such as XHTML, keep the XML.
Which YAML is supported?
YAML 1.2, read by the eemeli/yaml library, which is checked against the official yaml-test-suite: anchors and aliases, << merge keys, multi-line strings, custom tags, and several documents separated by ---, which become a list.
Is there a size limit?
Files up to 50 MB. Very large files take a few seconds, since everything runs in your browser.