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
- Open Convertee, set the source to JSON and the target to XML.
- Paste your JSON (an object or array of objects) into the input panel, or drop a
.jsonfile. - Configure options: root element name, XML declaration toggle, indent style, and attribute key prefix.
- Click Convert (Cmd+Enter).
- Copy the XML output or download it as an
.xmlfile.
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
- SOAP API integration. You have a JSON payload from your frontend and need to send it to a SOAP service that accepts only XML. Converting the JSON body to XML avoids building the envelope manually.
- Android resource generation. Android uses XML for strings, layouts, and configuration. If you manage translation strings as JSON, converting to XML produces files that Android Studio can consume directly.
- RSS feed creation. Building a podcast or blog RSS feed from a JSON data source becomes straightforward when you can generate the XML skeleton automatically.
- Data interchange with legacy systems. Banks, insurance companies, and government agencies often require XML submissions. Converting JSON exports from modern APIs to the expected XML schema bridges the gap.
Options and Configuration
| Option | Default | What It Does |
|---|---|---|
| Root element name | root | The name of the outermost XML element wrapping the entire document. |
| XML declaration | On | Prepends <?xml version="1.0" encoding="UTF-8"?> to the output. |
| Array item tag | item | Tag name used for each element within a JSON array. Set it to match your target schema (e.g., employee instead of item). |
| Indent | 2 spaces | Controls 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.