XML Generator
Generate XML from JSON data. Paste any JSON object or array and convert it to well-formed XML with configurable root element, indent, attribute prefix, and XML declaration.
Last updated: May 28, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is XML Generator?
An XML generator that converts JSON data to well-formed XML. This is the reverse of an XML-to-JSON converter — useful when you need to produce XML output from JSON data, integrate with SOAP or XML-based systems from modern JSON APIs, or build XML configuration and data files programmatically.
The tool intelligently handles JSON objects, arrays, and primitive values. Arrays are serialised as repeated same-name XML elements. Keys starting with @ are treated as XML attributes. The special key #text sets the text content of an element when attributes and children co-exist. This convention matches popular libraries like xml2js, fast-xml-parser, and xmlbuilder2.
How to Use XML Generator
Paste your JSON into the input area on the left
The XML output appears instantly on the right
Set the "Root Element" name to control the wrapper element (used when JSON has multiple top-level keys or is an array)
Use @ prefix in your JSON keys to create XML attributes (e.g., "@id": "1" → id="1")
Toggle "XML Declaration" to add or remove the <?xml ...?> header line
Click "Copy XML" or "Download .xml" to save the output
Common Use Cases
- Generating SOAP request bodies from JSON data
- Converting REST API JSON responses to XML for legacy system integration
- Creating XML configuration files from JSON settings
- Building XML data feeds from JSON objects
- Testing XML parsing tools by generating known XML from controlled JSON
- Generating Maven POM-like XML structures from JSON dependency lists
Example Input and Output
A JSON object with attributes and nested elements converted to XML:
{
"person": {
"@id": "42",
"@active": "true",
"name": "Alice Johnson",
"email": "alice@example.com",
"address": {
"street": "123 Main St",
"city": "Boston",
"zip": "02101"
},
"tags": ["developer", "designer"]
}
}<?xml version="1.0" encoding="UTF-8"?>
<person id="42" active="true">
<name>Alice Johnson</name>
<email>alice@example.com</email>
<address>
<street>123 Main St</street>
<city>Boston</city>
<zip>02101</zip>
</address>
<tags>developer</tags>
<tags>designer</tags>
</person>How This Tool Works
The JSON input is parsed with JSON.parse. A recursive serialiser walks the resulting JavaScript object tree. Object keys starting with the attribute prefix (@ by default) are emitted as XML attributes on the enclosing element. The special #text key sets mixed text content. Arrays produce repeated sibling elements with the parent key as the tag name. All values are XML-escaped (& → &, < → <, etc.). The output is assembled as a plain string.
Technical Stack
Privacy First
JSON to XML conversion runs entirely in your browser. Your JSON data is never transmitted to our servers.
Attribute Prefix Convention
The @ prefix for attributes matches the xml2js and fast-xml-parser convention used in Node.js ecosystems. If you are using a different convention (e.g., _ or -attr), you can change the attribute prefix in the options panel.

