JSON to XML Converter Online – Free, No Upload

Paste JSON, name the root element, and convert JSON to XML in your browser. The text stays on this page and is not uploaded.

JSON input

XML output

Convert JSON to see XML here.

Quick answer

This JSON to XML converter wraps your JSON in one root element, then writes nested objects as nested tags and arrays as repeated tags. For {"order": {"id": 1001, "total": 29.5, "items": ["pen", "book"]}} with root root and 2-space indent, the XML is:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <order>
    <id>1001</id>
    <total>29.5</total>
    <items>pen</items>
    <items>book</items>
  </order>
</root>

What this converter does

It reads the editor with JSON.parse, then walks the value and writes indented XML. Conversion runs in this browser. The JSON is not uploaded.

Use it when a SOAP API, a legacy system, or an enterprise feed expects XML and you already have JSON. Format the JSON first in the JSON Formatter or inspect it in the JSON Viewer if you need to read the structure before converting.

This page converts JSON to XML only. It does not convert XML back to JSON — that is a separate direction with different conventions. For YAML instead of XML, use the JSON to YAML converter or the YAML to JSON converter.

How to convert JSON to XML

Step 1: Add JSON

Paste JSON into the editor, choose Open JSON File, or choose Load Sample JSON. Open JSON File converts as soon as a valid file is read. Load Sample JSON converts immediately.

Step 2: Choose options

Name the root element (default root), pick 2-space or 4-space indentation, and keep the XML declaration on unless you need the fragment without it.

Step 3: Convert pasted JSON

Pasted JSON needs Convert to XML. Invalid JSON stays in the editor. The status line explains the problem in plain language, and the XML preview is cleared.

Step 4: Copy or download

Copy XML converts the current editor text, then copies that XML. Download XML converts the current editor text and saves converted-data.xml. Neither button copies a stale preview. Clear empties both panels.

How JSON maps to XML

The mapping is element-only, which is the common convention for this kind of converter.

Objects become nested elements

Each object key becomes a nested element. Nested objects nest further.

{"user": {"name": "Ada"}}
<root>
  <user>
    <name>Ada</name>
  </user>
</root>

Arrays become repeated elements

Array items share the same tag as the key.

{"items": ["pen", "book"]}
<root>
  <items>pen</items>
  <items>book</items>
</root>

Strings, numbers, and booleans become text

{"id": 1001, "active": true, "city": "Quetta"}
<root>
  <id>1001</id>
  <active>true</active>
  <city>Quetta</city>
</root>

Null becomes a self-closing tag

{"note": null}
<root>
  <note />
</root>

Invalid names are sanitized

Keys that start with a digit or contain spaces are rewritten with underscores so the XML names stay valid.

{"2nd item": 1}
<root>
  <_2nd_item>1</_2nd_item>
</root>

Arrays and nested objects

Nesting depth is kept. An object inside an array item becomes a nested element under that repeated tag. The items array below is two <items> elements; it is not one parent with numbered children.

{
  "order": {
    "id": 1001,
    "items": ["pen", "book"]
  }
}
<root>
  <order>
    <id>1001</id>
    <items>pen</items>
    <items>book</items>
  </order>
</root>

Attributes and text

A key that starts with @ becomes an attribute of its parent element. The @ prefix is dropped from the attribute name. A key called #text becomes that element’s text content.

{"book": {"@id": "7", "#text": "Dune"}}
<root>
  <book id="7">Dune</book>
</root>

Worked example

Input:

{"order": {"id": 1001, "total": 29.5, "items": ["pen", "book"]}}

Output with 2-space indentation, the XML declaration on, and root root:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <order>
    <id>1001</id>
    <total>29.5</total>
    <items>pen</items>
    <items>book</items>
  </order>
</root>

The top-level object is wrapped in <root> because XML needs exactly one root. order becomes a nested element. id and total become text elements. The items array becomes two repeated <items> elements.

Frequently asked questions

How do I convert JSON to XML online?

Paste your JSON, name the root element (default "root"), and press Convert to XML. The XML appears instantly with a declaration and indentation — copy it with the Copy XML button. Free, no signup.

What is the root element in XML?

XML needs exactly one top-level element, so the converter wraps your JSON in one. It defaults to "root" — name it whatever your target system expects, e.g. "catalog" or "response".

How are JSON arrays converted to XML?

Each array item becomes a repeated element with the same tag. ["pen", "book"] under "items" becomes <items>pen</items> followed by <items>book</items>.

How do I add attributes to XML from JSON?

Prefix the key with @: {"book": {"@id": "7", "#text": "Dune"}} makes <book id="7">Dune</book>. The @ is dropped from the attribute name.

What happens to null values?

Null becomes a self-closing tag, e.g. <note />. There is no text to put inside it.

Is my JSON uploaded?

No. The conversion runs entirely in your browser with JavaScript — your JSON is never sent to a server, logged or stored.

Can I convert XML back to JSON?

Not with this tool — it converts JSON to XML only, because the two directions need different conventions.

What if my JSON is invalid?

The converter tells you in plain language (e.g. a missing comma or an unquoted key) and produces no XML until the JSON parses. Fix the input, then convert again.

Disclaimer

Free tool, runs entirely in your browser. Nothing you paste is uploaded or stored.