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
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste JSON into the input area or click "Load Sample"
Set a root element name (default: root)
Toggle the XML declaration on or off
Choose 2 or 4 space indentation
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.
{
"server": {
"host": "localhost",
"port": 8080
},
"tags": ["api", "v2", "stable"]
}<?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.
Related Tools
XML to JSON Converter
Parse and convert XML to clean JSON instantly — attributes, namespaces, and nested elements handled.
YAML to XML Converter
Convert YAML to XML online. Supports nested objects, arrays, and custom root element names with optional XML declaration.
JSON Formatter
Format, validate, and beautify JSON instantly — with clear error messages, Tree View, Diff mode, and Schema validation.
JSON to CSV Converter
Convert a JSON array of objects to CSV. Flattens nested objects with dot-notation columns and handles arrays within values.
XML Beautifier
Format and prettify minified or messy XML with configurable indentation. Also minify XML to remove whitespace.
CSV to XML Converter
Convert CSV or TSV data into well-formed XML with configurable root and row element names, attribute or element mode, and optional XML declaration.

