Convertee/Guide

How to Convert JSON to XML: Complete Guide

Last updated: 2026-04-14

JSON dominates modern web development, but XML is far from obsolete. SOAP services, Android manifest files, Maven build configs, SVG graphics, and regulatory data submissions all require XML. When your data starts as JSON and the destination expects XML, a reliable converter saves you from hand-writing angle brackets and worrying about escaping rules.

Step-by-Step: Convert JSON to XML with Convertee

  1. Open Convertee, set the source to JSON and the target to XML.
  2. Paste your JSON (an object or array of objects) into the input panel, or drop a .json file.
  3. Configure options: root element name, XML declaration toggle, indent style, and attribute key prefix.
  4. Click Convert (Cmd+Enter).
  5. Copy the XML output or download it as an .xml file.

The conversion runs entirely in your browser. No data is uploaded to any server.

Understanding the Formats

JSON

JSON (RFC 8259) represents structured data with objects, arrays, and primitive values. It has no built-in concept of attributes, namespaces, or mixed content — all of which are native to XML. The converter maps JSON keys to XML element names and can optionally treat keys with a specific prefix (like @) as XML attributes.

XML

XML (W3C XML 1.0) uses a tree of nested elements with opening and closing tags. Each element can have attributes (key-value pairs in the opening tag) and child elements or text content. An XML document must have exactly one root element.

Before / After Example

Input JSON:

{
  "employees": [
    { "name": "Alice", "department": "Engineering", "active": true },
    { "name": "Bob", "department": "Design", "active": false }
  ]
}

Output XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <employees>
    <item>
      <name>Alice</name>
      <department>Engineering</department>
      <active>true</active>
    </item>
    <item>
      <name>Bob</name>
      <department>Design</department>
      <active>false</active>
    </item>
  </employees>
</root>

Common Use Cases

Options and Configuration

OptionDefaultWhat It Does
Root element namerootThe name of the outermost XML element wrapping the entire document.
XML declarationOnPrepends <?xml version="1.0" encoding="UTF-8"?> to the output.
Array item tagitemTag name used for each element within a JSON array. Set it to match your target schema (e.g., employee instead of item).
Indent2 spacesControls indentation. Choose 2 or 4 spaces, tabs, or minified (no whitespace).

Frequently Asked Questions

How are JSON arrays represented in XML?
Each array item is wrapped in an element tag. By default, the tag name is 'item', but you can customize it in the options to match your target schema (e.g., 'employee', 'product').
Can I generate XML attributes from JSON keys?
Yes. Keys prefixed with '@' (or your chosen prefix) are rendered as XML attributes on the parent element rather than child elements.
Does the output include an XML declaration?
By default, yes. The output starts with <?xml version="1.0" encoding="UTF-8"?>. You can turn this off in the options if your target system does not expect it.
What happens with null values in JSON?
Null values produce self-closing empty elements (e.g., <field/>) in the XML output. If you prefer to omit null fields entirely, you can remove them from the JSON before converting.

Related Guides

Ready to convert? Try it now — no sign-up required.

Open Converter