Skip to main content
chain
X
JSON to XML error
⌃⏎ run · clear · / focus input
// about this tool

JSON to XML Online

Updated 2026-08-19

Convert JSON to XML online for free, instantly in your browser. Paste JSON and SnapTools produces clean, properly indented XML — objects become nested elements and arrays become repeated tags — ready to copy or download. Nothing is uploaded; the conversion runs locally.

XML is still everywhere: SOAP services, RSS feeds, sitemaps, and countless enterprise and legacy systems expect it. This converter lets you take modern JSON data and express it as well-formed XML in a single step, with names sanitized and special characters safely escaped.

// how to use

  1. 1 Paste your JSON into the input panel.
  2. 2 SnapTools converts it to clean, indented XML as you type.
  3. 3 Adjust the settings bar if you need a different root element, indent width, no XML declaration, or attribute output.
  4. 4 Copy or download the XML for your API, config, or legacy system.

// examples

Attributes and text (@attrs on)
Input
{"book":{"@isbn":"978-1","@lang":"en","title":"Dune"}}
Output
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <book isbn="978-1" lang="en">
    <title>Dune</title>
  </book>
</root>
JSON to XML
Input
{"user":{"name":"Alice","roles":["admin","editor"]}}
Output
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <name>Alice</name>
    <roles>admin</roles>
    <roles>editor</roles>
  </user>
</root>

// common uses

Feeding JSON data into SOAP or XML APIs Generating RSS or sitemap fragments Integrating with legacy enterprise systems Producing XML config from JSON

// faq

Can I change the root element name?
Yes — type a name into the "Root" box in the settings bar. JSON has no single wrapper element and XML requires exactly one, so a root is always added; it defaults to <root>.
How do I output attributes instead of child elements?
Turn on "@attrs". Keys beginning with @ become attributes on their element and a #text key becomes the element's text, so {"@id":"7","#text":"hi"} produces <root id="7">hi</root>. These are the same conventions our XML to JSON converter emits, so the two tools round-trip: convert XML to JSON, edit it, convert it back, and your attributes survive.
Can I get XML without the <?xml ... ?> declaration?
Yes — switch off "XML declaration". That is what you want when the result is a fragment being embedded inside a larger document rather than a standalone file.
Why convert JSON to XML?
Many enterprise systems, SOAP APIs, RSS feeds, and legacy integrations still require XML. Converting lets you take modern JSON data and feed it into those systems.
How are JSON arrays represented in XML?
Each array item becomes a repeated element. Items inside a named array reuse that key as the element name; a top-level array uses <item> elements.
What happens to invalid XML element names?
JSON keys with spaces or other characters that aren't valid in XML names are sanitized (e.g. spaces become underscores), and names starting with a digit are prefixed so the output is always well-formed.
Are special characters escaped?
Yes — characters like &lt;, &gt;, and &amp; are escaped to keep the XML valid, and Unicode is preserved.
Is my data uploaded?
No — conversion happens in your browser, so nothing leaves your machine.

Use this via API

Get a free API key →
curl -X POST https://thesnaptools.com/api/v1/tools/json-to-xml \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"json":"{\"book\":{\"@isbn\":\"978-1\",\"@lang\":\"en\",\"title\":\"Dune\"}}"}'