About this tool
Plenty of systems still speak XML: SOAP services, RSS feeds, payment gateways, government and banking APIs, Android resources and enterprise integrations. This converter turns JSON into well-formed XML and gives you control over the parts that have no single right answer, such as arrays, attributes and nulls.
How JSON maps to XML
- Each key becomes an element:
{"name": "Ada"}→<name>Ada</name>. The whole document is wrapped in a root element (default<root>). - Arrays: with Repeat the element,
{"tag": ["a", "b"]}becomes<tag>a</tag><tag>b</tag>, the usual XML style. With Wrap items you get<tag><item>a</item><item>b</item></tag>, which keeps empty and one-item arrays unambiguous. - Attributes: keys starting with
@become attributes, and#textbecomes the element’s text, the same convention used by xml2js, Newtonsoft.Json and many converters. So{"price": {"@currency": "EUR", "#text": "12.50"}}→<price currency="EUR">12.50</price>. - null: an empty element, an
xsi:nil="true"element (what XML Schema and SOAP expect), or left out. - Special characters (
&,<,>, quotes) are escaped, and characters XML forbids are removed.
Invalid element names are fixed
JSON keys can be anything; XML names can’t start with a digit, contain spaces, or begin with “xml”. Keys like 2fa-verified or first name are rewritten (_2fa-verified, first_name), and the status line tells you which keys were renamed so you can adjust the receiving side.
XML has no types
Everything in XML is text, so 42, "42" and true all become plain text content. If the receiver needs types, it will get them from an XML Schema (XSD) or its own mapping. Converting back to JSON therefore can’t always restore numbers and booleans exactly.
Need YAML instead? Try JSON to YAML.
FAQ
How do I convert JSON to XML?
Paste JSON above. XML is generated instantly with a root element; you can rename the root and the element used for array items.
How are JSON arrays converted to XML?
By default each item repeats the parent element name, which is the common XML style. Choose “Wrap items” to put the items inside one element as <item> children instead.
How do I create XML attributes from JSON?
Prefix the key with @, for example {"book": {"@id": "7", "title": "Moby Dick"}} gives <book id="7"><title>Moby Dick</title></book>. Use #text for the element’s own text.
What happens to keys that are not valid XML names?
They are rewritten to valid names, for example a leading digit gets an underscore and spaces become underscores. The status line lists renamed keys.
How are null values written?
As an empty element by default. You can use xsi:nil="true", which XML Schema and SOAP use for null, or omit the element.