How to use this JSON to XML converter
Paste your JSON into the top box, choose a name for the root element, and press “Convert to XML”. The mapping is deliberately simple and predictable. Every object key becomes an element with that name; a nested object becomes nested elements; an array becomes one element per item, repeated in order; and strings, numbers and booleans become the text inside their element. The output is indented two spaces per level so the structure is easy to read, and it can be copied or downloaded as a .xml file.
The root name deserves a moment's thought. XML insists on a single element wrapping the whole document, while a JSON object has as many top-level keys as it likes — so the converter wraps your keys in one root element that you name. The default “root” is fine for quick jobs, but if the XML is headed for another system, name it after the document itself: person, order, product, configuration. Many receiving systems check the root name before they look at anything else.
Two safety details run automatically. Text values are escaped, so an ampersand in “Fish & Chips” cannot corrupt the document, and keys that could never be legal XML tag names — ones containing spaces or starting with a digit — are cleaned into valid names with underscores. If the JSON itself is broken, you get the parser's error message instead of half-converted output; fix it with the JSON Validator, then convert again.
Example: a person record as XML
This JSON, converted with the root name set to “person”:
becomes:
Notice the skills array: two items in JSON become two sibling elements with the same tag in XML. That repetition is the standard way XML carries a list, and any XML consumer — including the XML to JSON converter on this site — reads it back as an array in the same order.
The shape mismatch you should know about
JSON and XML were designed for different jobs, and a converter can bridge most of the gap but not all of it. XML has attributes — the id in <person id="7"> — and JSON has no equivalent, so this tool never invents them; everything becomes an element, which keeps the conversion reversible. XML also allows mixed content, text flowing around child elements inside the same parent, which JSON cannot express at all. And XML preserves no data types: the number 36 and the string "36" both become the text 36 inside a tag, so a system reading the XML must already know which fields are numeric. None of this makes the conversion unreliable — it makes it worth a quick review when the receiving system is strict about its input, especially around lists and empty values.
Where converted XML usually ends up
Most JSON-to-XML jobs exist because two systems disagree about format. A modern API returns JSON, but the invoicing platform wants an XML import; a web app holds its data as JSON, but the sitemap, the RSS feed or the SOAP service at the other end speaks only XML. There are also quieter uses: generating test fixtures for an XML parser, preparing sample documents for documentation, or feeding data into older desktop software that predates JSON entirely. In every case the pattern is the same — the data is fine, only the envelope is wrong — and a faithful, boring conversion like this one, with no values dropped and nothing silently reinterpreted, is exactly what the job needs. Before sending the result anywhere important, open it once in a browser or an XML-aware editor: well-formed documents display as a neat tree, while a structural problem is reported with its line, which makes a ten-second check a reliable final step.
Frequently asked questions
How are JSON arrays converted to XML?
Each array item becomes its own element with the array's key as its tag name, repeated in order. The JSON {"skill": ["math", "code"]} becomes two elements, <skill>math</skill> and <skill>code</skill>. XML has no native list type, so repeated sibling tags are the standard, widely understood way to represent one.
What happens to keys that are not valid XML tag names?
XML tag names may only contain letters, digits, underscores, hyphens and dots, and must not start with a digit. This converter replaces any other character with an underscore and prefixes names that start with a digit, so the output is always well-formed XML. If exact tag names matter, rename those keys in the JSON first.
Can this converter produce XML attributes?
No — every JSON value becomes an element, never an attribute. JSON has no concept of attributes, so any mapping to them would be a guess. Element-only output is the predictable choice: it converts back to the same JSON with an XML to JSON converter, which attribute-based output would not guarantee.
What does the root element name do?
XML documents must have exactly one root element wrapping everything. JSON objects have many top-level keys, so the converter wraps them in a single root whose name you choose — “root” by default. Pick a name that describes the document, such as person, order or catalogue, especially if another system will consume the XML.
How are nulls and empty values handled?
A JSON null or an empty object becomes an empty element such as <middleName />. Booleans are written as the text true or false, and numbers as their plain decimal text. Nothing is silently dropped — every key in the JSON appears in the XML.
Are special characters in my text escaped?
Yes. Ampersands and angle brackets inside string values are escaped as &, < and >, so a value like “Fish & Chips <large>” cannot accidentally break the document structure. Any standard XML parser reads them back as the original characters.
Should I include the XML declaration?
The declaration — <?xml version="1.0" encoding="UTF-8"?> — tells a parser the version and character encoding. Include it when the XML will be saved as a file or sent to another system; it is optional for quick snippets you paste into a config that already declares one. The checkbox adds or removes it.
Is my data uploaded for the conversion?
No. The conversion runs in JavaScript in your own browser. Your JSON is never sent to a server, stored or logged, and the page keeps working offline after it has loaded.
Why would anyone still need XML in a JSON world?
Plenty of living systems speak XML only: SOAP web services, RSS and sitemap files, SVG images, Office document formats, Android layouts and a long tail of enterprise and government integrations. Converting JSON to XML is usually about feeding one of those, not about preferring the format.