JSON to XML Converter Online — Free & Fast

Convert JSON to well-formed XML in seconds. Maps keys to elements, arrays to repeated tags, and nested objects to children — entirely in your browser.

What is a JSON to XML converter?

A JSON to XML converter transforms a JSON document — the dominant data format for modern REST APIs — into XML, the format still required by SOAP services, enterprise middleware, financial messaging systems, and many government APIs. Each JSON property becomes an XML element, nested objects become children, and arrays become repeated tags. The result is well-formed XML that any XML parser, XSLT pipeline, or schema validator can consume.

OpenFormatter's converter runs entirely in your browser. Your JSON — whether it's an order payload, a webhook event, or a database export containing PII — never touches a server. The output is indented for readability, wrapped in a <root> element, and uses element-only mapping (no attributes) to round-trip cleanly back to JSON if needed.

How to convert JSON to XML online — 4 steps

  1. Paste your JSON. Copy a REST response, a config file, or any valid JSON into the Input panel. Click Load Sample to try a demo order document.
  2. Click Convert. The tool parses the JSON in your browser and emits a UTF-8 XML document with a <root> wrapper.
  3. Review the XML. Each key becomes an element, arrays become repeated <item> tags, and invalid XML names (those with spaces, leading digits, or punctuation) are sanitised.
  4. Copy and integrate. Click Copy to grab the XML. Replace <root> with your target schema's document element (for example <soap:Envelope>) before sending.

Sample JSON and XML output

Input JSON

{
  "order": {
    "id": 4582,
    "currency": "USD",
    "customer": {
      "name": "Jane Doe",
      "email": "jane@example.com"
    },
    "items": [
      { "sku": "A-100", "qty": 2, "price": 19.99 },
      { "sku": "B-220", "qty": 1, "price": 49.50 }
    ]
  }
}

Output XML

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <order>
    <id>4582</id>
    <currency>USD</currency>
    <customer>
      <name>Jane Doe</name>
      <email>jane@example.com</email>
    </customer>
    <items>
      <item>
        <sku>A-100</sku>
        <qty>2</qty>
        <price>19.99</price>
      </item>
      <item>
        <sku>B-220</sku>
        <qty>1</qty>
        <price>49.5</price>
      </item>
    </items>
  </order>
</root>

Element-Only Mapping

Every JSON property becomes a child element with text content. No attribute mapping means objects round-trip cleanly back to JSON without losing structure.

Name Sanitisation

JSON keys with spaces, leading digits, or special characters are auto-sanitised to valid XML element names. Invalid input never produces broken XML.

Client-Side Only

Conversion is pure JavaScript executed in your browser. No upload, no logging, no rate limit — safe for payloads with secrets or PII.

Common use cases

  • check_circleBridging modern REST microservices with legacy SOAP middleware that requires XML envelopes
  • check_circleConverting JSON webhook payloads to XML for ingestion by mainframe and ERP systems
  • check_circleGenerating XML feeds for ecommerce platforms, RSS, sitemaps, or product catalogues from JSON sources
  • check_circlePreparing JSON test fixtures for XML-based unit tests, contract tests, and XSLT pipelines
  • check_circleMigrating data from MongoDB or DynamoDB JSON documents into XML-backed archival systems
  • check_circleProducing XML for regulatory filings (HMRC, IRS e-file, FATCA) that mandate XML schemas
  • check_circleTransforming JSON configuration into XML for older Windows applications and Java EE servers
  • check_circleRound-tripping data through XSLT for templated PDF, HTML, or document generation

JSON vs XML: when does this conversion make sense?

JSON dominates the public web because it is lighter, easier to read, and maps directly to JavaScript and Python data structures. XML still rules in three places: SOAP-based enterprise integration, document-oriented standards (DocBook, DITA, OOXML), and regulated industries that froze their schemas a decade ago. If your downstream consumer is one of those — a SOAP gateway, an XSLT-driven document pipeline, or a government filing system — converting JSON to XML is unavoidable. For everything else, prefer to keep JSON end-to-end. This converter is built for the unavoidable case.

Need to round-trip XML back to JSON?

Convert in either direction, format the result, or validate the JSON before sending — all in-browser.

Frequently Asked Questions

How are JSON arrays mapped to XML?

Each array element is wrapped in an <item> tag inside its parent element. So {"colors": ["red", "blue"]} becomes <colors><item>red</item><item>blue</item></colors>. This avoids ambiguity when the array is empty or contains a single element — both still parse as a list on the receiving end.

What root element does the converter use?

The output is wrapped in a single <root> element to satisfy XML's requirement of exactly one document element. If your target system expects a different root (e.g. <Envelope> for SOAP, <Order> for a domain document), search-and-replace <root> with the correct tag in the output.

Are JSON property names valid XML element names?

Not always. XML forbids spaces, leading digits, and most punctuation in element names. The converter sanitises invalid characters to underscores and prefixes names that start with a digit (so "1stItem" becomes "_1stItem"). Review the output if your JSON keys contain unusual characters.

Does the output map values to XML attributes or elements?

This converter uses element-only mapping — every JSON property becomes a child element with text content. Attribute mapping (key="value") is conventional in some XML schemas but loses information when values are themselves objects. Element-only output is safer and round-trips more cleanly.

Are special characters in values escaped?

You should escape five XML-reserved characters in element text: & (&amp;), < (&lt;), > (&gt;), " (&quot;), and ' (&apos;). For binary or markup-rich content, wrap the value in CDATA: <![CDATA[ raw text ]]>. The converter emits raw values; if your JSON contains < or &, post-process the output for full conformance.

Why does my SOAP service reject the converted XML?

SOAP requires a soap:Envelope root, a soap:Body wrapper, and (often) a target namespace declaration on the payload. The plain XML this tool produces is well-formed but not a SOAP envelope. Wrap the converted body in your envelope template and add xmlns attributes manually.

Can JSON null be expressed in XML?

XML has no native null. Conventions vary: an empty element (<status></status>), an xsi:nil="true" attribute (requires the XSI namespace), or the literal text "null". This converter emits the text "null" for JSON null values — adjust if your schema requires xsi:nil semantics.

Is my JSON sent to a server?

No. Conversion runs entirely in your browser using JavaScript. JSON containing customer data, API keys, or proprietary payloads never leaves your device. Open DevTools Network tab and verify — no request fires when you click Convert.

JSON to XML Converter Online — Free & Fast | OpenFormatter