BYTETOOLS

How to Convert JSON to XML Online (Step by Step)

To convert JSON to XML, paste your JSON into the ByteTools JSON to XML Converter, choose a root element name and indentation, and click Convert to XML. You get clean, well-formed, indented XML with escaped text and a standard XML declaration, ready to copy or download.

XML is still the language of SOAP services, legacy integrations, and many feed and config formats. This tutorial walks the whole conversion, explains each setting, and shows why doing it in the browser keeps your data private.

Step-by-step: JSON to XML

  1. Load your JSON. Paste it in, or drop a .json file to load it.
  2. Set the root element name. It defaults to root; name it after your document, such as order or catalog.
  3. Choose indentation. Pick 2 spaces, 4 spaces, or a tab to match your house style.
  4. Click Convert to XML. Object keys become elements, arrays become repeated <item> elements, and values become escaped text.
  5. Copy or download. Send the XML to your clipboard or save it as a .xml file.

A worked example

Given this input:

{ "order": { "id": 7, "tags": ["new", "paid"] } }

with root root you get:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <order>
    <id>7</id>
    <tags>
      <item>new</item>
      <item>paid</item>
    </tags>
  </order>
</root>

The array became repeated <item> elements, which keeps the XML well-formed because element names cannot be numeric indexes.

What each setting does

Setting or behaviourEffect
Root elementWraps the whole document; defaults to root, invalid characters sanitised.
Indentation2 spaces, 4 spaces, or a tab for readable output.
ArraysEach element becomes a repeated <item>.
Text escaping&, <, and > are escaped to entities automatically.
XML declarationOutput starts with <?xml version="1.0" encoding="UTF-8"?>.

Why do it in the browser

The conversion runs entirely in your browser with JavaScript, so your JSON is never uploaded. That makes it safe for configuration data, API payloads, and anything you would rather keep private, and it works offline once loaded.

Try the JSON to XML Converter — free and 100% in your browser.

FAQ

What root name should I use?

Use a name that describes the document, like catalog or response. If you leave it blank the tool uses root, and invalid characters are replaced so the result is always valid.

How are arrays represented?

Each array element is written as a repeated <item> inside its parent element, which keeps the document well-formed.

Does it add an XML declaration?

Yes. The output begins with a standard UTF-8 XML declaration so it is ready to save or send.

Are special characters handled?

Yes. Ampersands and angle brackets are escaped to their XML entities automatically, so any standards-compliant parser can read the output.

Related free tools

Built by ByteVancer

ByteTools is a free product of ByteVancer, a software and web development studio building web apps, SaaS, and custom software. When you need more than a converter, explore what ByteVancer can build.