Skip to content

JSON to XML Converter

Paste any JSON document and get well-formed XML with a declaration, a root element you choose, and repeated elements for arrays. Nothing leaves your browser.

Loading editor...
Paste or type JSON
Loading editor...
XML output
Auto-run ON

How to convert JSON to XML

  1. Paste your JSON into the left panel, upload a .json file, or load it from a URL.
  2. The XML appears on the right as you type. Pick a Root element name (<root>, <data>, <document>, or <response>) to match what the receiving system expects.
  3. If the top level of your JSON is an array, choose the Array item name (<item>, <element>, <row>, or <entry>) used for each entry.
  4. Click Copy or Download .xml.

If the input is not valid JSON, the error bar shows the line and column. Click Fix to repair trailing commas, single quotes, or comments before converting.

What the output looks like

Input:

{
  "orderId": 1042,
  "customer": { "name": "Maya & Co", "vip": true },
  "items": [
    { "sku": "A-100", "qty": 2 },
    { "sku": "B-220", "qty": 1 }
  ],
  "ship date": "2026-06-23",
  "notes": null
}

Output:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <orderId>1042</orderId>
  <customer>
    <name>Maya &amp; Co</name>
    <vip>true</vip>
  </customer>
  <items>
    <sku>A-100</sku>
    <qty>2</qty>
  </items>
  <items>
    <sku>B-220</sku>
    <qty>1</qty>
  </items>
  <ship_date>2026-06-23</ship_date>
  <notes xsi:nil="true"/>
</root>

Four rules explain everything above:

  • Arrays become repeated elements named after their key, so items appears once per entry with no wrapper. A root-level array uses the Array item name instead.
  • null becomes xsi:nil="true", and the xsi namespace is declared on the root only when a null is present.
  • Keys are sanitised into valid XML names: spaces and other illegal characters become _, a key starting with a digit gets a leading _, and names beginning with xml are prefixed as well.
  • Text is entity-escaped: &amp;, &lt;, &gt; and &quot; replace the literal characters so the output is always well-formed.

Limits and notes

  • Files up to 5 MB. Conversion runs as JavaScript in your browser; nothing is uploaded.
  • There is no schema, so the tool cannot know whether a value should be an attribute or a child element. Everything becomes an element.
  • Numbers and booleans are written as plain text, since XML has no types of its own. Converting back with XML to JSON restores them only when type detection is on.
  • Key order is preserved. Empty objects become self-closing tags such as <meta/>.
  • Arrays of arrays have no natural XML shape: the inner arrays are flattened into repeated elements with the same name. Restructure first if that nesting matters.
  • Still choosing a format? Read JSON vs XML, and see JSON key naming conventions for keys that convert cleanly.

Frequently Asked Questions

Why do array items repeat the parent key instead of getting a wrapper?
That is the most common JSON-to-XML convention. An array called items produces one items element per entry with no extra wrapper. XPath handles it naturally, and an XML-to-JSON converter turns the repeated siblings back into an array.
How are null values represented?
As an empty element with xsi:nil="true", which is the XML Schema way to say a value is explicitly null rather than an empty string. The xsi namespace is declared on the root element automatically whenever a null appears.
What happens to keys that are not valid XML names?
They are rewritten so the output stays well-formed. Spaces and symbols become underscores, a key starting with a digit gets a leading underscore, and keys beginning with xml are prefixed because that name is reserved. Rename keys in the JSON first if exact names matter.
Can I turn a value into an attribute instead of an element?
Not with this tool. JSON has no way to mark a value as an attribute, so every value becomes a child element. In the reverse direction, the XML to JSON converter keeps attributes as @_name keys.
Is my data uploaded?
No. The conversion runs as JavaScript in your browser tab. You can go offline after the page loads and the tool keeps working.

Guides that go with this tool

More JSON tools

JSON Viewer (Tree View)

Explore any JSON document as a collapsible tree in your browser. Click a key to copy its JSONPath, click a value to copy it, and page through large arrays without freezing the tab.

JSON Fixer: Repair Invalid JSON

Repair broken JSON in your browser. Strips markdown fences and prose, fixes trailing commas, single quotes, comments, unquoted keys, Python literals and unclosed brackets, and lists every problem it detected.

JSON to CSV Converter

Convert a JSON array of objects to CSV in your browser. Nested objects are flattened to dotted columns, values are quoted correctly, and Excel-friendly output is one click away.

CSV to JSON Converter

Convert CSV with a header row into a JSON array of objects in your browser. Numbers and booleans are detected, leading-zero codes stay strings, and the delimiter is picked up automatically.

JSON to YAML Converter

Convert JSON to clean YAML in your browser with 2, 3 or 4 space indentation. Strings that a YAML parser would read as numbers, booleans or dates are quoted so they survive the round trip.

YAML to JSON Converter

Convert YAML to JSON in your browser. Multi-document files become an array, anchors and aliases are resolved, and only null, true, false and plain numbers are typed, so yes, NO and dates stay strings.

XML to JSON Converter

Convert XML to JSON in your browser. Attributes are kept as @_name keys, repeated tags become arrays, numbers and booleans are detected, and invalid XML reports the line and column.

JSON Compare (Diff)

Compare two JSON documents in your browser and get a structural diff that lists every changed, added, and removed value with its JSONPath. Key order and whitespace are ignored.

JSONPath Query Tester

Test JSONPath expressions against your JSON in the browser. Pick an expression, see the matches as a JSON array with a count, and explore the results in tree view.

JSON Escape / Unescape

Escape text into a JSON string literal, unescape one back to plain text, or stringify a whole JSON document to embed it inside another JSON value or in source code.