Kadben

Convert XML to JSON

Choose an XML file or paste XML to get JSON with a documented, reversible mapping. Errors in the XML are shown with line and column.

Runs in your browser. Nothing is uploaded.

XML to JSON

Input
Options

The result appears here.

How to use it

  1. Choose an XML file, drop it on the box, or paste XML into the text field; the result appears at once.
  2. Check the options: whether repeated elements are arrays everywhere, which elements should always be arrays, and the indentation.
  3. Look at the preview, then download the .json file or copy the result.
  4. If the XML has an error, the message shows the line and the column. Fix it: pasted text is converted again as you type.

Rules and limits

XML and JSON mapping

Questions and answers

Why are all numbers in quotes?

XML has no data types, so every value is converted as a string. Turning "00123" or "1e5" into numbers would change the data. Convert the types in your own code, where you know which fields are numbers.

When does an element become an array?

When it appears more than once under the same parent. With “Repeated elements as arrays everywhere” on (the default), an element that repeats anywhere becomes an array at the same path in every record, so all records have the same shape. For elements that never repeat in this file, enter their names under “Always arrays”.

Can I convert the JSON back to XML?

Yes, with JSON to XML, which uses the same mapping: namespace prefixes and declarations are kept as keys, so the namespaces come back. Comments, processing instructions, CDATA sections and the order between different element names are not kept.

Related tools