Skip to content
ToolMug

JSON to XML Converter

Produce XML from JSON for older APIs, configuration files or SOAP-style integrations. The output is indented, starts with an XML declaration and is checked to be well-formed.

Runs in your browser — nothing you enter is uploaded

JSON → XML
Output (XML)

How to use

  1. Paste JSON or load the sample.
  2. Choose the indentation.
  3. Copy the XML or download it.

Options explained

Attributes
Keys that start with @, such as "@id", become attributes; "#text" becomes the element text.
Arrays
An array becomes the same element repeated once per item.
Root element
XML needs exactly one root. If the JSON is an array or has several top-level keys, everything is wrapped in <root>.

Example

The @id key becomes an attribute, the array becomes repeated item elements and null becomes an empty element. The input has exactly one top-level key, so that key is the root element.

{"order": {"@id": "A1", "customer": "Ada", "item": [{"name": "Pen", "qty": 2}, {"name": "Ink", "qty": 1}], "note": null}}
<?xml version="1.0" encoding="UTF-8"?>
<order id="A1">
  <customer>Ada</customer>
  <item>
    <name>Pen</name>
    <qty>2</qty>
  </item>
  <item>
    <name>Ink</name>
    <qty>1</qty>
  </item>
  <note/>
</order>

When the top level is an array, such as [{"a": 1}, {"a": 2}], the result is a root element containing one item element per entry, each holding the a element.

Frequently asked questions

Are invalid element names fixed?

No. Keys with spaces or starting with a digit are not valid XML names; rename them in the JSON first.

How are null values written?

As empty elements, such as <middleName/>.

Can I convert the XML back?

Yes. Use XML to JSON; with the same @ and #text conventions the round trip keeps attributes and text.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools