XML to JSON

Convert XML into JSON.

Updated
Loading tool…

Convert XML into JSON.

How to use XML to JSON

  1. Paste your XML document into the input box
  2. Let the built-in parser convert it to JSON
  3. Copy the equivalent JSON for your code or API
Try next →JSON FormatterFormat, repair and validate JSON.

About XML to JSON

XML to JSON takes an XML document and rewrites it as equivalent JSON. It is the tool to reach for when you have data or a config file in XML and need it in JSON to use in code, feed to an API, or drop into something that only speaks JSON. Paste the XML in and the converted JSON comes back ready to copy — whether you call it converting, transforming, or parsing XML to JSON, it is the same one-step job here.

The structure is mirrored as closely as the two formats allow: elements become keys, nested elements become nested objects, and attributes and repeated tags are represented in a consistent way. XML has features JSON does not — attributes, mixed text-and-element content, the order of repeated tags — so those are handled as sensibly as possible, and very complex documents are worth a quick manual check afterwards. If you were otherwise going to script this in Python, this page saves you writing any code for a one-off file.

Everything runs in your browser using its own built-in XML parser, so the XML you paste is read locally on your own device and never uploaded to a server. It is free, works online with no account or sign-up, has no usage limits, and there is nothing to install.

Frequently asked questions

Is it free, and is there a sign-up?
Yes, it is completely free with no account or sign-up. You can convert as many times as you like, with no usage limits.
Does my XML get uploaded?
No. The tool uses the browser's own XML parser to read your data, so everything is processed locally on your device. Your XML is never sent to any server, which also makes it safe for files you would rather not share.
How do I convert XML to JSON here, and what do I get back?
Paste your XML into the input box and the tool returns the equivalent JSON, which you can copy out. The result is standard JSON text you can save or paste straight into your own code. There is nothing else to configure.
Does it work online without downloading anything?
Yes. It runs entirely in the browser online, with nothing to download or install. Because the parsing happens on your device rather than a server, it keeps working even on files you would rather not upload anywhere.
Can this convert JSON back to XML?
This tool converts in one direction — XML into JSON. To go the other way, from JSON to XML, you would use a separate JSON-to-XML converter, since translating JSON back into XML follows different rules for tag names and attributes. So this page is the right choice when your starting point is XML.
How do I convert XML to JSON in Python instead?
If you would rather do it in code, Python's xmltodict library or the built-in xml.etree.ElementTree module can parse XML into a dictionary you then dump as JSON. For a single file, though, pasting it here is quicker than writing and running a script. This page is handy when you just need the JSON once and do not want to set anything up.
Will the JSON match my XML exactly?
It mirrors the structure of your XML, with elements becoming keys and nested elements becoming nested objects. Because XML and JSON are different formats, things like attributes and repeated elements are represented in a consistent way that can read a little differently from the original.
How are XML attributes handled in the JSON?
Attributes are preserved in the output rather than dropped. Because JSON has no direct notion of an attribute, they are represented in a consistent way that can read a little differently from the raw XML, but the values are all still there.
What happens to repeated tags and lists?
When the same tag appears several times inside a parent, those repeated elements are represented consistently so the group stays together rather than collapsing into a single value. This is how list-like data in XML carries over into the JSON.
Are there cases where the conversion is tricky?
XML has features JSON does not, such as attributes, mixed text-and-element content, and the order of repeated tags. These are handled as sensibly as possible, but very complex or irregular XML may need a manual check afterwards.