Skip to content
M2TOOLKIT

Developer · free tool

JSON to XML Converter

Convert JSON data into well-formed, indented XML.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Developer
  • Free
  • No sign-up
  • Runs in your browser
  • Updated
Keys starting with @ become attributes; #text becomes element text.

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us.

How to use the JSON to XML Converter

  1. Paste your JSON into the left box, or open a file.
  2. Adjust the options if you need to.
  3. Copy the XML or download it as a file.

What does this tool do?

Objects become nested elements and arrays become repeated elements with the same name. Keys that aren't valid XML names are made safe automatically, and special characters are escaped.

Exactly how JSON is mapped to XML

JSON has no attributes, no text-plus-children elements and no required root, while XML has all three, so a converter has to follow conventions. This tool uses the common ones: a key starting with @ becomes an attribute, a key named #text becomes the text of an element that also has attributes, and an array is written as repeated elements that share the key's name.

XML needs exactly one root element, and JSON does not name one, so the tool wraps your data in a root element called "root" unless you change the name. Output is indented and starts with an XML declaration (version 1.0, UTF-8).

Element names can only contain letters, digits, underscores, hyphens and dots, and cannot start with a digit. Keys that break this are repaired rather than rejected: a key such as "first name" becomes first_name, "2fa" becomes _2fa and "a&b" becomes a_b. Values are escaped, so x < y is written as x &lt; y.

Related: XML to JSON converter · XML formatter · JSON validator

What to check before using the XML elsewhere

Numbers, booleans and null all become plain text, because XML has no data types. true is written as the text true, and a consumer that expects a boolean has to parse it. An empty array produces no elements at all, so the key disappears from the output.

If the system receiving the XML expects a specific schema (a SOAP service, a sitemap, an invoice format), this tool will not validate against it. It guarantees well-formed XML, not a particular structure. Check element order and required fields against that system's documentation.

Why use it?

  • Integrate with XML-based systems and SOAP APIs.
  • Generate feeds and config files.
  • Attribute support with the @ prefix.

Worked example: an order with an attribute, a list and an empty value

Input JSON: {"order":{"@id":"1001","customer":"Ana","items":{"item":["Pen","Ink"]},"note":null,"total":12.5}}. With the root name left as "root", the output is below. Notice the @id key became an attribute, the two-item array became two <item> elements, and null became a self-closing <note/>.

JSONXML output
"@id": "1001"<order id="1001">
"item": ["Pen", "Ink"]<item>Pen</item> and <item>Ink</item>
"note": null<note/>
"total": 12.5<total>12.5</total>

Privacy

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.

Frequently asked questions

When would I need XML instead of JSON?

Many older enterprise systems, SOAP web services, RSS feeds, sitemaps and some government and banking interfaces still require XML. JSON is more common for modern web APIs.

What happens to special characters like & and <?

They're escaped automatically (&amp; and &lt;), so the output is always well-formed XML.

Content last updated . See how M2Toolkit works.

Other tools people use alongside the json to xml converter.