JSON to XML Converter

Convert JSON to XML as you type.

How to convert JSON to XML

  1. Paste JSON into the left box. The XML document appears on the right as you type.
  2. Set the Root element name. It is used when the JSON is an array or has more than one top-level key, because an XML document must have exactly one root.
  3. Choose the indent, then copy the XML or select Download to save converted.xml.
  4. Use Swap to open the XML to JSON converter with the result filled in.

The conversion runs in your browser and nothing you paste is sent to a server.

Example

This JSON:

{"book": {"@_id": "bk101", "title": "XML Basics", "author": ["Ada", "Alan"], "price": 29.99}}

becomes this XML:

<?xml version="1.0" encoding="UTF-8"?>
<book id="bk101">
  <title>XML Basics</title>
  <author>Ada</author>
  <author>Alan</author>
  <price>29.99</price>
</book>

Frequently asked questions

How do I create XML attributes and text?

Keys that start with @_ become attributes of their element, so "@_id": "bk101" becomesid="bk101". A #text key sets the text of an element that also has attributes, for example{"price": {"@_currency": "EUR", "#text": 9.5}}. This is the same mapping the XML to JSON converter produces, so the two round-trip.

How are arrays converted?

XML has no arrays, so each array item becomes a repeated element with the array's key as its name. A top-level array is wrapped in the root element with one <item> per entry.

Why do I get an "is not a valid XML name" error?

XML element names cannot contain spaces or start with a digit, so a key like "first name" or"2024" cannot become an element. Rename the key in the JSON. Special characters in values, such as& and <, are escaped for you.