JSON to XML Converter

Convert JSON into well-formed XML.

JSON to XML Converter tool

XML has no arrays, so each entry becomes a repeated element.

About the JSON to XML Converter

Modern services produce JSON, but older enterprise systems, SOAP endpoints and some government and banking integrations still require XML. This JSON to XML converter rewrites a JSON document as well-formed XML, letting you name the root element and the elements used for repeated array items, and escaping special characters such as ampersands and angle brackets correctly. The result is indented for easy reading. Keys that are not valid XML element names are adjusted so the output always parses. For the opposite direction, use the XML to JSON Converter, and to check the JSON first, the JSON Formatter.

JSON and XML do not line up perfectly, so the converter has to make a few choices, and it is open about each one. Keys become element names, values become the text inside those elements, and lists turn into repeated sibling elements, because XML has no list type of its own. Where the key's name would make a valid element name, the repeated elements are named after it.

Element names are where trouble usually starts. An XML name may not begin with a digit, may not contain spaces and cannot be empty, while a JSON key can be any text at all. Keys that would break those rules are changed in a predictable way and every change is reported, so you never receive XML that quietly fails to parse.

Special characters are escaped throughout. Ampersands, angle brackets and quotation marks inside values become entities, so text that contains markup cannot damage the document, and the indented result reads cleanly in any XML parser. The whole conversion takes place in your browser, so configuration data, customer records and internal feeds are never sent to a server.

How to use the JSON to XML Converter

  1. Paste the JSONAny valid document: an object, a list or even a single value.
  2. Name the root elementXML must have exactly one outer element, something JSON does not require.
  3. Choose the indentationTwo spaces, four spaces or a tab.
  4. Take the XMLCopy it or download the well-formed file.

JSON to XML Converter features

  • Well-formed XML output with indentation
  • Lists written as repeated sibling elements
  • Unusable element names fixed and reported instead of breaking the file
  • Ampersands, angle brackets and quotation marks escaped correctly
  • Root element name of your choice
  • Clear JSON error messages showing where the problem is
  • Conversion carried out entirely in your browser

Common uses

  • Sending JSON data to a system that only accepts XML
  • Preparing a request body for a SOAP web service
  • Moving a configuration file from one format to the other
  • Producing XML for a data import routine
  • Seeing how the same data is expressed in both formats

JSON to XML in practice: courier and ERP integrations, wrapper elements, element order and schemas, namespaces and encodings

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Many established systems, including courier booking services, banking interfaces, government portals and enterprise software, still exchange data as XML. Developers whose applications work in JSON regularly need to produce XML that these systems accept on the first attempt. This guide works through sending an order to an XML-based system, explains how to shape JSON so the output matches the expected structure, and covers schemas, element order, namespaces, data types and encoding.

A worked example: sending an order

A courier's booking interface expects XML with an order element containing an ID, the destination city and a list of items. Starting from this JSON:

  • {"order": {"id": "1042", "city": "Lahore", "items": {"item": [{"sku": "KT-01", "qty": 2}, {"sku": "DP-07", "qty": 1}]}}}

the converter produces an order element with id and city children, and an items element containing two item elements, each with sku and qty. The wrapping items object with an item array inside is deliberate: it produces the common pattern of a plural container holding singular children, which most XML schemas expect.

Shaping the JSON first

If the JSON had simply contained an items array, the result would be repeated items elements with no container. Neither form is wrong, but only one will match what the receiving system expects. Looking at a sample XML file from the system's documentation and arranging the JSON to mirror it, before converting, saves rounds of rejected requests.

Element order and schemas

Many systems validate incoming XML against a schema, often an XSD file. Schemas frequently require child elements in a fixed sequence, so an order with city before id may be rejected even though the data is correct. JSON object order is usually preserved when converting, so arranging keys in the order the schema lists them produces valid output.

Namespaces and envelopes

SOAP services and some formal standards require namespaces, written as prefixes such as soap:Envelope, and a surrounding envelope element. JSON has no equivalent, and a key containing a colon may be rewritten to keep the output valid. A practical approach is to convert the business data to XML, then place it inside the envelope copied from the service's sample request, checking the namespace addresses exactly.

Types become text

XML element content is text, so numbers, true and false and null lose their JSON types. The receiving system decides how to interpret each value, usually according to its schema. Check how it expects booleans and empty values to be written, such as true or 1, and whether a missing value should be an empty element or left out entirely.

Encodings

UTF-8 handles Urdu and every other script, and most modern systems expect it. Some older systems declare a different encoding, such as ISO-8859-1, which cannot hold Urdu letters directly; there, characters outside the encoding must be written as numeric character references. Testing with a real Urdu name or address early in an integration avoids surprises after launch.

Testing the output

Validate the generated XML against the system's schema if one is provided, using a validator or a test endpoint. Send a small test order first and compare the system's response with its documentation. Keeping a set of working sample requests makes future changes, and troubleshooting, much faster.

Common mistakes

  • Converting JSON as it is instead of shaping it to the target structure.
  • Ignoring the element order a schema requires.
  • Forgetting the envelope and namespaces required by SOAP services.
  • Testing only with English text.

Related tools

To convert responses back into JSON, use XML to JSON Converter. To indent and check the output, try XML Formatter, and to tidy the source data, JSON Formatter.

Dates and numbers in schemas

XML schemas usually expect dates as YYYY-MM-DD and date-times such as 2026-10-25T14:30:00+05:00, with an explicit time zone offset. Decimal values must use a full stop and no thousands separators. Formatting these values correctly in the JSON before converting avoids validation errors that can be hard to trace in long responses.

Empty and single-item lists

Lists behave differently at the edges. A list with one item produces a single element, which some receiving code mistakes for a non-list value, and an empty list may produce no element at all, while the system may expect an empty container. Testing with zero, one and several items catches these differences before real orders are sent.

File size

XML writes every element name twice, in the opening and closing tags, so the same data is noticeably larger than in JSON. Compression reduces the difference considerably when sending over the network. Systems that accept batches often limit the size or number of records per request, so large uploads may need splitting into several smaller requests.

Keeping copies for support

Saving a copy of each request and response, with personal details removed, makes troubleshooting much faster. When an integration fails, the partner's support team almost always asks for the exact payload that was sent and the response received. Having these ready turns a long email exchange into a quick fix.

Privacy

Conversion runs entirely in your browser. Orders, addresses and other data are not uploaded or stored.

Frequently asked questions

What happens to JSON arrays?

Each item becomes its own element, and the items sit side by side under the key, because XML has no array type. A key called items holding three values gives three item elements inside one items element.

What if a key would be an invalid XML name?

It is changed into a valid one: forbidden characters are replaced, and a letter is added at the front of a name that started with a digit. Each change is listed, so you can see exactly what was altered.

Is an XML declaration added at the top?

Yes, a standard declaration specifying UTF-8 is placed on the first line, which is what most parsers and import routines expect to find before the root element.

Does the output use XML attributes?

No. Everything becomes an element, because JSON cannot tell an attribute apart from an ordinary child value. If the receiving system needs attributes, the usual approach is to adjust the XML afterwards.

Are characters such as & and < handled safely?

Yes. Ampersands, angle brackets and quotation marks are written as entities like &amp; and &lt;, so values that contain markup or symbols cannot break the structure of the document.

Is my JSON uploaded?

No. The conversion happens entirely within your browser, so the data you paste is never sent to a server, stored or logged by this site or anyone else.