Conversion Tools

JSON to XML

This free JSON to XML converter turns a JSON object into indented XML in your browser: each key becomes an element, nested objects become nested elements, and array items repeat as sibling elements inside an XML declaration and a <root> element. Paste your JSON, click Convert to XML, and copy the result; nothing is uploaded.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.

Convert JSON to XML Online

The Tools Kit’s free JSON to XML converter turns a JSON object into indented XML in your browser. Paste JSON from an API response, a config file, or test data, click Convert to XML, and copy the result. Each key becomes an element, nested objects become nested elements, and arrays become repeated elements, all inside an XML declaration and a single<root> element.

Nothing is uploaded: the JSON is parsed and the XML is assembled by JavaScript on your own device. If your JSON is messy or minified, tidy it first with the JSON formatter so parse errors are easier to spot.

How to Convert JSON to XML

  1. 1

    Paste your JSON

    Paste a JSON object into the JSON Input box, or edit the sample that is already filled in. The top level should be an object wrapped in curly braces.

  2. 2

    Click Convert to XML

    The JSON is parsed in your browser. If it is not valid, an "Invalid JSON" message explains what the parser could not read.

  3. 3

    Review the XML output

    The right-hand panel shows the XML with an XML declaration, a root element, and two-space indentation for each nesting level.

  4. 4

    Copy the result

    Click Copy XML to put the converted markup on your clipboard, ready to paste into a file, request body, or config.

There is no account to create and no limit on how many conversions you run.

How JSON Maps to XML: A Worked Example

JSON and XML describe data differently. JSON has objects, arrays, strings, numbers, booleans and null; XML has only elements, attributes and text. This converter uses the most common element-only mapping. Here is a small order record:

{
  "order": {
    "id": 7,
    "items": [
      { "sku": "A1", "qty": 2 },
      { "sku": "B2", "qty": 1 }
    ],
    "note": "Fish & chips",
    "paid": true,
    "coupon": null
  }
}

Clicking Convert to XML produces exactly this output:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <order>
    <id>7</id>
    <items>
      <sku>A1</sku>
      <qty>2</qty>
    </items>
    <items>
      <sku>B2</sku>
      <qty>1</qty>
    </items>
    <note>Fish &amp; chips</note>
    <paid>true</paid>
    <coupon>null</coupon>
  </order>
</root>
  • Objects — order becomes an <order> element containing one child per key.
  • Arrays — the two entries in items become two sibling <items> elements; there is no extra wrapper.
  • Numbers and booleans — written as plain text (7, true), since XML text carries no data type.
  • null — written as the text null, not as an empty or omitted element.
  • Reserved characters — the ampersand in “Fish & chips” is escaped to &amp;.

Getting Valid XML From Your JSON

Because JSON allows almost any string as a key but XML names are strict, a few inputs need preparing before conversion. Key names are copied straight into tag names, so:

  • Start with an object. A top-level array gives tags named <0>, <1> and so on, which are not legal XML. Wrap it, for example {"item": [ ... ]}.
  • Avoid spaces and leading digits in keys. "first name" or "2024" make invalid tags; rename them to something like first_name or y2024.
  • Expect arrays of arrays to flatten. Inner arrays are not nested; their items join the same run of repeated sibling elements.
  • Empty arrays disappear. A key holding [] produces no element in the output.

After converting, paste the result into the XML formatter to validate and re-indent it. If you only need to escape a snippet of text for HTML or XML rather than convert a whole document, the HTML entity encoder handles that.

JSON vs XML: When You Still Need XML

JSON is the default for modern web APIs, but XML remains common in SOAP web services, RSS and Atom feeds, sitemaps, Android resources, Maven and .NET project files, and many enterprise, banking and government data exchanges. Converting JSON to XML is usually about feeding data from a JSON-speaking system into one of these XML-only consumers.

Going the other way, the XML to JSON converter turns XML back into JSON. For spreadsheet-friendly output, try JSON to CSV, and if your source data is in YAML, convert it with YAML to JSON first and then run it through this tool. All of these live in the conversion tools collection.

Common uses

  • Turning a JSON API response into an XML request body for a SOAP or legacy service
  • Generating XML test fixtures or sample payloads from existing JSON data
  • Migrating configuration values from a JSON file to an XML config format
  • Seeing how a JSON structure would look as XML before writing a conversion script
  • Teaching or learning the differences between the two data formats side by side

JSON to XML terms explained

TermWhat it means here
ElementA named pair of tags such as <name>Alice</name>; every JSON key becomes one
Root elementThe single outer element an XML document must have; this tool always uses <root>
XML declarationThe first line, <?xml version="1.0" encoding="UTF-8"?>, stating the XML version and character encoding
AttributeA name="value" pair inside an opening tag; JSON has no equivalent, so this converter never creates attributes
EntityAn escaped stand-in for a reserved character, such as &amp; for & or &lt; for <
Well-formed XMLXML that follows the syntax rules: one root, properly nested and closed tags, legal tag names, escaped text

Frequently Asked Questions

Reviewed by Raja Jahangir · Last reviewed: October 7, 2026

How do you convert JSON to XML?

To convert JSON to XML, paste a JSON object and click Convert to XML. Each key becomes an element, nested objects become nested elements, arrays repeat the element once per item, and the output is wrapped in a <root> element with an XML 1.0 UTF-8 declaration. Special characters such as < and & are escaped automatically.

Sources and standards