WebToolsPlanet
Converter Tools

JSON to XML Converter

Paste JSON and convert it to structured XML instantly. Nested objects become nested elements, arrays produce repeated sibling elements, and the root element name is configurable.

Last updated: May 21, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is JSON to XML Converter?

JSON and XML are both formats for structured data, but they serve different ecosystems. JSON is the standard for web APIs and modern applications; XML is dominant in enterprise systems, SOAP services, Android resources, configuration files, and many legacy integrations. Converting between them is a routine task when bridging these worlds.

This tool recursively maps JSON to XML: objects become parent elements with children, arrays become repeated sibling elements with the parent's key as the tag name, and scalar values become text content. Keys that are invalid XML element names are automatically sanitised. The root element name is configurable to match your target schema.

How to Use JSON to XML Converter

1

Paste JSON into the input area or click "Load Sample"

2

Set a root element name (default: root)

3

Toggle the XML declaration on or off

4

Choose 2 or 4 space indentation

5

Copy or download the XML output

Common Use Cases

  • Developers converting JSON API responses to XML for consumption by SOAP-based enterprise services.
  • Engineers transforming JSON configuration to XML format required by Java or .NET frameworks.
  • Architects migrating data from JSON-based APIs to XML-based data interchange formats.
  • Developers generating Android XML resources (strings.xml, etc.) from JSON source data.
  • Teams converting JSON data files to XML for XSLT transformation pipelines.
  • Data engineers transforming JSON exports to XML for import into XML databases or legacy systems.

Example Input and Output

A JSON configuration object with nested structure and an array is converted to well-formed XML.

JSON input
{
  "server": {
    "host": "localhost",
    "port": 8080
  },
  "tags": ["api", "v2", "stable"]
}
XML output
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <server>
    <host>localhost</host>
    <port>8080</port>
  </server>
  <tags>api</tags>
  <tags>v2</tags>
  <tags>stable</tags>
</root>

Privacy

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

Attribute vs element style

This converter uses the element-per-value style (child elements for all values). Some XML schemas use attributes for simple values. If your target schema requires attributes, post-process the output or use an XSLT transform to convert child elements to attributes.

Frequently Asked Questions

How are JSON arrays converted to XML?
JSON arrays produce repeated sibling elements using the parent key as the tag name. For example, "tags": ["api","v2"] produces <tags>api</tags><tags>v2</tags>. This follows the most common XML array convention.
What happens to null values?
JSON null values are converted to self-closing XML elements, e.g. "key": null becomes <key/>.
What if my JSON keys are not valid XML element names?
XML element names cannot start with digits or contain spaces and most special characters. Invalid characters are replaced with underscores, and names starting with a digit get an underscore prefix.
What is the root element?
XML requires a single root element wrapping all content. Since JSON can have multiple top-level keys, all content is wrapped in a configurable root element (default: <root>). Change this to match your schema.
Is my JSON sent to a server?
No. All conversion runs in your browser. Your JSON never leaves your device.