Data & Text tool

JSON to XML

Convert JSON into equivalent XML, with attributes and arrays handled sensibly.

JSON to XML Runs on your device
  • Runs in your browser — nothing you enter is uploaded
  • No sign-up, no quotas, free to use as often as you like

How it works

JSON and XML can express most of the same things, but not in the same way, so any conversion involves a few decisions. This makes the usual ones and tells you what they were.

Arrays become repeated elements

XML has no list type. The standard convention is to repeat the element once per item, so an array of three books becomes three <book> elements side by side. That is what nearly every XML consumer expects and what this produces.

Attributes

XML distinguishes attributes from child elements; JSON has no equivalent. The widely used convention is to prefix a key with @ to mean it should become an attribute, and that is followed here — it can be switched off if your keys genuinely start with @.

Names are made legal

XML element names cannot contain spaces or most punctuation and cannot begin with a digit. Keys that would break those rules have their invalid characters replaced with underscores and, where needed, gain a leading underscore. Without that, the output would not parse.

Nulls

A null becomes an empty element marked xsi:nil, which is the conventional way to say deliberately empty rather than missing. If your consumer does not understand xsi:nil, an empty element is usually read the same way.

The round trip is not exact

JSON distinguishes the number 42 from the string "42", and XML does not — everything in XML is text unless a schema says otherwise. Converting back will not reliably restore the original types.

FAQ

JSON to XML — questions

How are arrays handled?

As repeated elements, which is the standard XML convention since XML has no list type.

Can I produce attributes?

Yes. Prefix a key with @ and it becomes an attribute, which can be turned off.

What happens to keys with spaces?

Invalid characters become underscores, because XML names cannot contain them. Without that the output would not parse.

Can I convert back to JSON?

Yes, with the XML to JSON tool, but types are not preserved — XML has no notion of a number versus a string.

Is my data uploaded?

No. It is converted in your browser.