Tools

XML ⇄ JSON Converter

Convert XML to JSON and JSON to XML

How to convert XML to JSON

  1. Choose XML → JSON and paste your XML, for example a SOAP response, RSS feed, sitemap, Android resource or config file.
  2. Elements become JSON keys, attributes become keys starting with @ (change the prefix if your code expects another), and text inside an element that also has attributes or children goes in #text.
  3. Repeated elements, such as several <item> tags, become arrays. Tick Always use arrays if you want every element as an array so your code never has to check.
  4. Switch to JSON → XML to go the other way, using the same conventions.

Mapping rules

XML and JSON do not map one-to-one: XML has attributes, mixed content and ordering, while JSON has arrays and typed values. This converter uses the widely used conventions also found in libraries such as xml2js and fast-xml-parser, so the output is predictable:

Values stay strings when converting from XML, because XML has no types. When converting JSON to XML, arrays repeat their parent element name, null becomes an empty element, and keys that are not valid XML names are made safe.

Everything runs in your browser using its native XML parser. Nothing is uploaded.

Why are my numbers strings in the JSON?

XML text has no data types, so the converter keeps every value as a string to avoid damaging IDs, postcodes or version numbers. Convert types in your code where needed.

What happens to XML namespaces?

Prefixed names like soap:Body are kept as keys including the prefix, and xmlns declarations appear as attributes.

Can it convert large XML files?

Files of several megabytes convert in a moment. Very large files are limited by your browser's memory.