JSON to XML · 5 min read
Convert JSON to XML for Legacy System Integration
Modern applications love JSON for its simplicity. But many enterprise systems — ERP platforms, banking APIs, government data exchanges, and supply chain networks — still require XML. This guide explains how to convert JSON to valid XML using the JSON to XML Converter, covering arrays, data types, and custom element names that legacy systems expect.
Why Legacy Systems Need XML
Enterprise software built before the JSON era relies on XML for structured data exchange. Common scenarios include:
- SOAP web services — older enterprise APIs that require XML-formatted requests.
- EDI systems — Electronic Data Interchange platforms that use XML wrappers.
- Banking and finance — ISO 20022 and SWIFT-compatible XML messages.
- Government interfaces — tax filings, customs declarations, and public records often mandate XML.
- Internal legacy tools — in-house systems built on XML-based configuration and data exchange.
Instead of writing custom XML serialization code, use the converter to transform JSON into the expected XML format instantly.
1. Mapping JSON Arrays to XML Elements
JSON arrays are the most common challenge when targeting XML. Consider order data from a modern e-commerce API:
{
"order": {
"orderId": "ORD-2026-001",
"customer": {
"name": "Acme Corp",
"account": "AC-4412"
},
"products": [
{"sku": "W-100", "qty": 5, "unitPrice": 24.99},
{"sku": "W-200", "qty": 3, "unitPrice": 39.99},
{"sku": "W-300", "qty": 10, "unitPrice": 14.99}
],
"total": 374.80,
"currency": "USD"
}
}
Set the Root Element to OrderRequest and Array Item to product. The tool produces:
<?xml version="1.0" encoding="UTF-8"?>
<OrderRequest>
<order>
<orderId>ORD-2026-001</orderId>
<customer>
<name>Acme Corp</name>
<account>AC-4412</account>
</customer>
<products>
<product>
<sku>W-100</sku>
<qty>5</qty>
<unitPrice>24.99</unitPrice>
</product>
<product>
<sku>W-200</sku>
<qty>3</qty>
<unitPrice>39.99</unitPrice>
</product>
<product>
<sku>W-300</sku>
<qty>10</qty>
<unitPrice>14.99</unitPrice>
</product>
</products>
<total>374.8</total>
<currency>USD</currency>
</order>
</OrderRequest>
Each array item becomes a repeating XML element. The products array wrapper is preserved, and each product becomes a <product> child.
2. Data Type Handling in XML
The converter maps JSON types to XML text content:
- Strings → XML text content (e.g.,
<name>Alice</name>) - Numbers → number-as-text (e.g.,
<price>24.99</price>— no quotes) - Booleans →
<active>true</active>orfalse - Null → omitted from XML output (no empty element)
- Arrays → repeating elements with the same tag name
- Objects → nested child elements
The output is valid, well-formed XML that legacy systems can parse without issues.
3. Custom Root and Element Names
Enterprise systems often expect specific tag names. The converter lets you configure:
- Root Element — the top-level wrapper tag (default:
root). Set it to match your target schema, likeOrderRequestorInvoiceBatch. - Array Item — the name for array child elements (default:
item). Name it based on what the array contains, likeproduct,lineItem, orrecord.
These settings are available in the converter's configuration panel. Changes update the XML preview in real time.
Try the Free JSON to XML Converter
Convert JSON to valid XML for enterprise legacy system integration. Custom root and array element names supported. No signup, no tracking.
Convert JSON to XML Now →Best Practices for JSON to XML Enterprise Conversion
- Match expected element names. Check your target system's XML schema (XSD) and set the Root Element and Array Item names to match. Mismatched tag names are the most common integration failure.
- Avoid special characters in values. XML restricts certain characters (
&,<,>) — the converter auto-escapes these, but it's better to clean the JSON first. - Validate the XML output. Paste the result into the JSON Editor to check that the source JSON was clean before converting again.
- Handle encoding. The converter outputs UTF-8 encoded XML. Ensure your legacy system accepts UTF-8 (most modern systems do).
- Test with sample data first. Run a small test conversion before processing large batches to verify the element names and structure match your target system's requirements.
Frequently Asked Questions
How do I convert JSON arrays to XML elements?
JSON arrays become repeating XML elements with the same tag name. For example, an array of products becomes multiple <product> elements. You can also customize the array item tag name using the Array Item setting in the JSON to XML converter.
How does the converter handle JSON data types in XML output?
JSON numbers become XML text content (no quotes), booleans become 'true' or 'false' text, strings become text content, and null values are omitted. The converter does not add xsi:type annotations — values are output as plain XML elements.
Can I set custom root and array element names?
Yes. Use the Root Element setting to set the top-level wrapper tag (default 'root'), and Array Item setting to name array child elements (default 'item'). This is useful when the target system expects specific tag names.
How does the converter handle deeply nested JSON objects?
Nested JSON objects become nested XML elements. The nesting depth is preserved exactly. Each level of nesting becomes a child element under its parent, making the XML structure match the JSON hierarchy.
Is my JSON data safe when converting to XML?
100% safe. All conversion happens in your browser. Your JSON data never leaves your computer. No server uploads, no storage, no tracking.