Free Online JSON to XML Converter

Paste JSON below to generate well-formed XML.

Input Ready

Input statistics are available via the Stats button above this field.

Output

Output statistics are available via the Stats button above this field.

Results are provided for informational purposes only and may contain errors. Please verify important information independently. Use of this tool is at your own risk.

What the JSON to XML Converter does

The JSON to XML Converter rewrites a JSON document as indented XML with an XML declaration. Object keys become element names and values become element text.

The output is always wrapped in a single <root> element, because XML allows only one top-level element. In a top-level array, each object becomes an <item> element. An array inside an object becomes repeated elements with the same name. A key that starts with @_ becomes an attribute instead of a child element.

When to use it

  • Sending data to a SOAP service, an older enterprise system or a partner feed that only accepts XML.
  • Producing test fixtures for an XML parser from data you already have as JSON.
  • Checking how a JSON structure would look as XML before designing a schema.

Worked example

Input

{"order": {"@_id": "A-17", "item": ["pen", "ink"], "total": 12.5}}

Output

<?xml version="1.0" encoding="UTF-8"?>
<order>
  <__id>A-17</__id>
  <item>pen</item>
  <item>ink</item>
  <total>12.5</total>
</order>

Common questions about the JSON to XML Converter

How do I create an XML attribute?

Prefix the key with @_. For example, "@_id": "A-17" inside order produces <order id="A-17">. The XML to JSON Converter uses the same prefix, so the round trip keeps attributes.

Why is everything inside a <root> element?

An XML document must have exactly one root element, while JSON can have several top-level keys or an array. Wrapping in <root> always produces well-formed XML. Rename it after converting if your system expects a different name.

Can I check the XML afterwards?

Yes. Paste it into the XML Validator to confirm it is well formed, or the XML Formatter & Beautifier to change the layout.

Frequently Asked Questions

How are JSON arrays represented in the XML?

Each item in an array becomes its own repeated XML element under the same parent tag, so the order and count of items is preserved.

Can I go the other direction, XML to JSON?

Yes - see the XML to JSON converter, or just swap the source/target dropdowns above and click the swap (⇄) button.

Is this tool free?

Yes, it's free to use. No signup, no email required. Get results on this page.

How do I get my result?

Use the tool on this page. Your result appears here; no email delivery is required.