What Is a JSON to XML Converter?
A JSON to XML converter transforms JSON objects and arrays into XML markup. Modern APIs speak JSON, but many enterprise platforms, SOAP services, payment gateways, government portals, e-commerce feeds (such as Google Merchant Center), publishing systems and legacy integrations still require XML. This tool bridges the two formats in one step.
The converter produces well-formed XML: special characters like &, < and quotes are escaped, invalid tag names are made safe, arrays become repeated elements, and keys starting with @ can become XML attributes. That gives you full control over the output structure.
How to Convert JSON to XML
- Paste JSON into the input box or upload a .json file.
- Name the elements. Set the root element name and the element name used for array items.
- Choose formatting. Pick indentation and whether to include the
<?xml?>declaration. - Copy or download the generated XML file.
JSON to XML Mapping Rules
| JSON | XML |
|---|---|
{"name": "Alice"} | <name>Alice</name> |
{"tags": ["a", "b"]} | <tags>a</tags><tags>b</tags> |
{"user": {"@id": 7, "name": "Bo"}} | <user id="7"><name>Bo</name></user> |
{"price": {"@cur": "USD", "#text": 9}} | <price cur="USD">9</price> |
null | Self-closing element <field/> |
| Top-level array | Wrapped in the root element with item elements |
Features
- Well-formed outputAll text and attribute values are XML-escaped correctly.
- Attribute mappingUse
@keyfor attributes and#textfor element text. - Safe tag namesKeys with spaces or invalid characters are converted into valid XML names.
- Custom root and itemsName the root element and array items to match your schema.
- Pretty or minifiedReadable indentation, or compact output for transmission.
- Round-trip friendlyUses the same conventions as our XML to JSON converter.
Common Uses for JSON to XML Conversion
- SOAP web services: build request bodies for enterprise, banking, travel and logistics APIs that only accept XML.
- Product feeds: generate XML feeds for Google Merchant Center, price-comparison sites and marketplaces from JSON product data.
- Sitemaps and RSS: turn JSON lists of pages or articles into XML sitemap and RSS structures.
- Configuration: create XML configuration for Java (Maven, Spring), .NET (
app.config) and Android resources. - Data exchange: satisfy government, healthcare (HL7) and finance integrations that mandate XML payloads.
Worked Example
This JSON:
{ "order": { "@id": "A17", "customer": "Jane", "items": ["Coffee", "Bagel"] } }
becomes:
<?xml version="1.0" encoding="UTF-8"?>
<order id="A17">
<customer>Jane</customer>
<items>Coffee</items>
<items>Bagel</items>
</order>
The single top-level key order is used as the root element, so the "Root element" setting only applies when the JSON has several top-level keys or is an array.
Well-Formed XML: What the Converter Guarantees
A well-formed XML document has exactly one root element, properly nested and closed tags, quoted attribute values and escaped special characters. The converter guarantees all of these. The five reserved characters are always escaped: & as &, < as <, > as >, " as " and ' as '. Element names are sanitised to follow XML naming rules: they must start with a letter or underscore and may contain letters, digits, hyphens, underscores and periods.
If your integration also requires validation against an XSD schema, structure your JSON to mirror the schema's elements and attributes, then validate the output with your schema tooling.
Frequently Asked Questions
Can I convert large JSON files?
Yes. JSON files of several megabytes are converted in about a second, because the conversion happens locally without any upload.
How is boolean and numeric data written?
Numbers and booleans are written as text content, for example <price>9.99</price> and <active>true</active>, because XML has no native data types. Schemas can declare their types if needed.
Can I add a namespace?
Yes. Add it as an attribute key, such as "@xmlns": "http://example.com/ns" or "@xmlns:soap": "...", on the element that should declare it.
Is the XML declaration required?
It's optional for UTF-8 XML, but recommended. Untick "Include XML declaration" if you are inserting the XML into another document.
Can I produce minified XML?
Yes. Choose "Minified" under Indentation to output the XML on a single line with no whitespace between elements.
How do I create XML attributes from JSON?
Prefix the key with @. For example, {"book": {"@id": "b1", "title": "XML"}} becomes <book id="b1"><title>XML</title></book>.
What happens to JSON arrays?
Arrays inside objects become repeated elements with the key's name. A top-level array is wrapped in the root element, with each entry named by the "Array item element" setting.
Why did some key names change?
XML element names cannot contain spaces or start with a digit. Invalid characters are replaced with underscores to keep the XML valid.
Is this tool free and private?
Yes. It is free, unlimited and runs entirely in your browser.