Figuro.net

XML to JSON Converter

Paste XML to get JSON, or paste JSON to get XML. Attributes, repeated elements and nested structures are kept, the result updates as you type, and everything runs in your browser.

Processed entirely on your device. Nothing is uploaded.

How this XML and JSON converter works

The tool reads your XML with the browser’s built-in XML parser, which also checks that the document is well formed, then walks through the elements and writes them out as JSON. Going the other way it parses your JSON and writes matching XML elements. Both directions update as you type.

How XML maps to JSON

XML and JSON do not describe data in exactly the same way, so converters follow conventions. This one uses the most common ones:

In XMLIn JSON
<name>Ann</name>"name": "Ann"
An attribute, id="1"A key starting with @, "@id": "1"
Text next to attributes or child elementsA "#text" key
The same element repeatedAn array of values
An empty element, <a/>An empty string

The same rules are used in reverse when you convert JSON to XML, so a document converted there and back keeps its structure. One exception is a list with a single item, which becomes a single element and comes back as one value instead of a one-item array.

Limits worth knowing

History and background

XML 1.0 became a W3C Recommendation on 10 February 1998. It was designed as a simpler form of SGML that could carry structured data across the web, and it quickly became the basis of configuration files, office documents, feeds and web services.

JSON grew out of the object syntax of JavaScript. Douglas Crockford specified it and promoted it as a lightweight data format in the early 2000s, and it was later standardised as RFC 4627 in 2006, ECMA-404 in 2013 and RFC 8259 in 2017. Its shorter notation and direct fit with programming languages made it the default for web APIs, which is why so much older XML data now needs converting.

Frequently asked questions

How do I convert XML to JSON? Choose XML to JSON, paste your XML or open a file, and the JSON appears on the right as you type. Use Copy or Download to take the result.

How do I convert JSON to XML? Choose JSON to XML and paste your JSON. If the JSON has one top-level key, it becomes the root element. Otherwise the data is wrapped in a root element whose name you can set.

What happens to XML attributes? With the attribute option on, each attribute becomes a key starting with @, for example "@id": "1". Turn the option off to leave attributes out of the JSON.

How are repeated elements handled? When the same element appears more than once under one parent, the values are collected into a JSON array. A single occurrence becomes a plain value.

Why does my XML show an error? The XML must be well formed: every tag closed, attribute values in quotes, and one root element. The error message from the parser usually points to the line and column of the problem.

Are numbers kept as numbers? By default every value is text because XML has no number type. Switch on the option to convert numbers and true or false to JSON types, but leave it off for IDs and postal codes with leading zeros.

Is my data sent anywhere? No. The conversion runs entirely in your browser, so private or confidential data stays on your device.

← Browse all calculators