JSON to XML: Convert JSON into Well-Formed XML
Part of Text tools: See all Text tools.
What is JSON To XML?
JSON to XML Converter turns a JSON document into well-formed, indented XML. Objects become nested elements, a list under a key becomes repeated sibling elements with that key's name, keys that start with @ become attributes, a #text key becomes the element's text, null becomes an empty element, and true/false are written as lowercase text. The conversion runs on our server for your request; the text is not saved.
How to use JSON To XML
- Paste your JSON into the input box.
- Click Convert.
- Check the XML output: a single top-level key becomes the root element (for example {"order": {...}} gives <order>); anything else is wrapped in <root>.
- Copy the XML from the output box and validate it against your target system's schema if it has one.
Why use this tool?
SOAP services, older enterprise imports and some government or banking portals still accept only XML, while most modern APIs speak JSON. This converter gives you a clean starting point without writing a script, and it uses the same @attribute and #text convention as the XML to JSON tool on this site, so simple documents can make the round trip.
JSON To XML — In-Depth Guide
JSON and XML describe the same kind of tree, but they do not map one-to-one. JSON has arrays, numbers, booleans and null; XML has elements, attributes, text, namespaces and mixed content where text and child elements sit side by side. Any converter has to pick a convention for the gaps. This one follows the widely used xmltodict-style rules: @ for attributes, #text for text that sits next to attributes, and repeated elements for lists.
The output is always well-formed XML with a declaration line and two-space indentation, and special characters such as &, < and > are escaped for you. Well-formed is not the same as valid for a particular system, though. If the receiving system publishes an XSD schema, it may require a specific element order, namespaces or data formats (for example ISO dates), so run the result through that schema or a test import before relying on it.
Types do not survive the trip into XML. The number 42, the string "42" and the boolean true all become plain text inside an element, because XML itself has no data types without a schema. If the reverse conversion matters, keep the original JSON as your source of truth.
For very large or automated jobs, a library in your own code (xmltodict in Python, fast-xml-parser in JavaScript, Jackson in Java) is the better choice. Use this page for quick one-off conversions, checking how a payload will look, or preparing a sample for a colleague.
Frequently asked questions
- How are JSON arrays converted?
- A list under a key repeats that element, so {"tag": ["a", "b"]} becomes <tag>a</tag><tag>b</tag>. A top-level array is wrapped in <root> with one <item> per entry, and a list nested directly inside another list uses <item> elements.
- How do I create XML attributes?
- Prefix the key with @. {"book": {"@id": "7", "title": "Hi"}} becomes <book id="7"><title>Hi</title></book>. Use a #text key for text next to attributes, like {"note": {"@type": "a", "#text": "hello"}}.
- What happens with null, true and false?
- null becomes an empty element such as <nick />, and booleans are written as the text true or false. Numbers are written as they appear in the JSON.
- What if a key is not a valid XML name?
- Characters XML does not allow in names (spaces, symbols) are replaced with an underscore, and a name that starts with a digit gets a leading underscore, so "first name" becomes <first_name> and "2fa" becomes <_2fa>.
- Can I choose the root element name?
- There is no separate option. Wrap your data in one top-level key, for example {"invoice": {...}}, and that key becomes the root element. Otherwise the root is <root>.
- Is my JSON stored?
- No. The text is sent over HTTPS, converted on our server for that request and not saved. Avoid pasting secrets such as API keys or passwords into any online tool.
- Is this tool free?
- Yes. It is free with no sign-up.
Also try
Related tools that work well with this one: