Home Text Tools Math & Numbers Developer Tools Date & Time Image Tools Blog
JSON ↔ XML Converter

Convert JSON to XML for SOAP Services and Legacy APIs

Your app speaks JSON but the bank or ERP wants XML. Learn how to map objects, arrays and attributes, then wrap the result for a legacy endpoint.

Sooner or later a modern project meets a system that only accepts XML: a bank gateway, an ERP import, a government service, an older enterprise SOAP endpoint. Your data is already in JSON, and rewriting it by hand invites typos. The JSON ↔ XML Converter does the mechanical part in the browser, but a few details decide whether the other side accepts the result.

JSON ↔ XML Converter FREE online toolRuns in your browser. No sign-up, nothing to install. Open the tool

Know what the target expects before you convert

Ask for the WSDL or an XSD schema and, ideally, one sample request that the system has accepted. Legacy services are strict about element names, element order and namespaces, and a sample is the fastest way to see all three.

Compare the sample with your JSON. Mark the fields that become XML attributes (for example id="42") rather than child elements, because a plain JSON-to-XML conversion normally produces elements only.

How JSON structures map to XML

JSON has objects, arrays, strings, numbers, booleans and null. XML has elements, attributes and text. The mapping is not one-to-one, so check each of these cases in the output:

  • An object becomes an element with child elements, one per key.
  • An array becomes repeated sibling elements, since XML has no array type. This converter names every one of them item, so rename them to match what the target expects.
  • Numbers and booleans become plain text; the receiver decides how to parse them.
  • null is written out as the text null by this converter, which many systems treat differently from an empty or missing element.
  • Keys that start with a digit or contain spaces are not valid XML element names and must be renamed first.

Convert a request step by step

Work with a small sample first, then scale up to real payloads.

  1. Paste a representative JSON object into the converter and run the conversion.
  2. Copy the XML and compare element names with the sample the service accepted.
  3. Rename any JSON keys that differ from the schema and convert again.
  4. Add the wrapper the protocol requires. A SOAP 1.1 message needs an Envelope and Body in the http://schemas.xmlsoap.org/soap/envelope/ namespace; SOAP 1.2 uses http://www.w3.org/2003/05/soap-envelope.
  5. Check the XML declaration at the top of the output, which the converter adds as <?xml version="1.0" encoding="UTF-8"?>, and change it if the endpoint wants something different.
  6. Send the request to a test environment and read the fault message if it fails.

Pitfalls that cause rejected messages

Element order matters when the schema uses xs:sequence. JSON objects are unordered in principle, so if your keys come out in a different order than the XSD expects, reorder them before sending.

Special characters are the second classic problem. Ampersands and angle brackets in text must be escaped as &amp; &lt; and &gt;. This converter writes values as they are, so check a value such as "Smith & Sons" in your sample and escape the characters yourself where needed.

Dates deserve attention too. JSON has no date type, so you probably store a string. Legacy XML often wants the xs:dateTime form, for example 2026-03-15T09:30:00Z, or a bank-specific pattern. Convert the format in your source data, not in the XML afterwards.

Finally, keep sensitive payloads in mind. Because the conversion happens in your browser, a test record does not travel to a third party, but you should still use sample data rather than real account numbers while experimenting.

Going back the other way

Responses from these systems are usually XML as well. Paste the response into the converter in the opposite direction to see it as JSON, which makes it easier to read nested fields and to write the mapping code in your own language. Remember that a single repeated element becomes an array only when it appears more than once, so write your parsing code to accept both a single object and a list.

Try the free JSON ↔ XML Converter
Runs in your browser. No sign-up, nothing to install.

Comments (0)

No comments yet. Be the first to share a thought.