⚙️ Developer Tools Free Forever

JSON to XML Converter – Convert JSON Data to XML Free Online

Convert any JSON object or array to properly nested, formatted XML. Customize root tags, array item names, indentation, and attribute prefixes. Download the result as a .xml file.

Examples:
Root element
Array item tag
Indent spaces
JSON Input
XML Output
About This Tool

How This JSON to XML Converter Works

This JSON to XML converter recursively walks your JSON document and maps each key value pair to an XML element. Objects become parent elements with child elements for each property. Arrays are converted to repeated sibling elements sharing the same tag name, which you can customize (default: “item”).

The attribute prefix feature lets you mark specific JSON keys as XML attributes rather than child elements. Any key starting with “@” is converted to an attribute on its parent element when this option is enabled. This is useful for generating XML that must match a schema expecting attributes rather than child nodes.

All JSON values are properly XML escaped: ampersands, angle brackets, quotes, and apostrophes are converted to their entity equivalents. The output is valid, well formed XML ready to download or use directly in integrations, data pipelines, and APIs that require XML input.

What this tool does

Converts JSON objects, arrays, and primitives
Custom root element and array item tag names
@ prefix for XML attribute generation
Configurable indentation (2, 4, or compact)
Optional XML declaration header
Download as .xml or copy to clipboard

How to use it

1

Paste JSON

Paste your JSON in the left panel or pick an example to get started immediately.

2

Set options

Name your root element, set the array item tag, choose indentation, and toggle the XML declaration.

3

Convert

Click Convert to XML. The formatted output appears immediately in the right panel.

4

Copy or download

Copy XML to clipboard or download it as a .xml file for your integration or data pipeline.

Common Questions

Questions About the JSON to XML Converter

JSON arrays are converted to repeated sibling XML elements. By default each item gets the tag name “item”, but you can set any name in the Array item tag field. For example, a JSON array of user objects with Array item tag set to “user” will generate multiple <user></user> elements inside the root element. If the root JSON is an array, all items are wrapped inside the root element you specify.

When enabled, any JSON key starting with @ is converted to an XML attribute on its parent element rather than a child element. For example, {“@id”:”123″,”name”:”Alice”} becomes <item id=”123″><name>Alice</name></item>. This lets you pre annotate your JSON to control which values become attributes in the XML output.

This tool converts JSON to XML only. For XML to JSON conversion, look for a dedicated XML to JSON converter tool. Reversing the conversion is non trivial because XML has concepts (attributes, namespaces, processing instructions, mixed content) that have no direct JSON equivalent, so different tools may produce different JSON structures from the same XML.

Yes. All five XML special characters are escaped: & becomes &amp;, < becomes &lt;, > becomes &gt;, double quotes become &quot;, and apostrophes become &apos;. The output is well formed XML and will pass any XML parser without issues.

JSON null values are represented as self closing elements with the xsi:nil=”true” attribute, following the XML Schema standard convention for absent or null values. For example, {“middleName”:null} becomes <middleName xsi:nil=”true”/>.

The converter sanitizes JSON keys to produce valid XML tag names. Spaces and invalid characters are replaced with underscores. Keys starting with a digit or special character get a leading underscore. For example a key “123 foo bar” becomes “_123_foo_bar” as an XML element name. This ensures the output is always well formed XML even with unconventional JSON key names.

There is no hard limit imposed by the tool, but very large JSON documents (several MB or more) may be slow to convert because the processing runs in your browser’s JavaScript engine. For production use with large datasets, use a server side library like xml2js (Node.js), lxml (Python), or JAXB (Java) which are optimized for throughput.

No. The entire conversion runs in your browser using JavaScript. Your JSON data never leaves your machine. This makes the tool safe to use with internal APIs, sensitive configuration data, and any JSON that contains credentials or personal information.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful. Check our detailed privacy policy here.