JSON to XML

  • Valid names
  • Escaped text
  • Nothing uploaded

Elements from keys, repeated tags for arrays, everything correctly escaped.

Input
XML

Paste input on the left to see xml.

Everything runs in your browser — nothing is uploaded.

About to xml

Converting JSON to XML maps object keys to element names and array items to repeated elements. JSONic sanitises names XML does not permit, escapes text content for the five predefined entities, and marks nulls with nil="true". The transformation is one-way, so treat the XML as an export rather than a round trip.

XML is still what a lot of enterprise and legacy systems accept. Keys become element names with invalid characters replaced, since XML names cannot start with a digit or contain spaces. Array elements are wrapped in repeated item tags, null becomes an element with nil="true", and text content is escaped for the five predefined entities.

Questions

What happens to keys that are not valid XML names?

Characters XML does not allow in a name become underscores, and a leading digit gets an underscore prefix. The transformation is not reversible, so treat the XML as an export rather than a round-trip format.

How are arrays represented?

As repeated <item> elements inside an element named after the key. XML has no array type, so this is the conventional encoding.

Are attributes ever produced?

No — everything becomes elements, apart from nil="true" on nulls. JSON carries no distinction between what should be an attribute and what should be an element, so guessing would produce inconsistent output.