Convert JSON to XML
online, free & instant
Paste your JSON and get well-formed XML output in one click. Handles nested objects, arrays, and element mapping. Works entirely in your browser — no upload, no account, no waiting.
Open JSON to XML ConverterFrom JSON to well-formed XML in seconds
No account. No upload. No nonsense.
100% Private
Your JSON never leaves your device. There is no server receiving your data.
Instant Output
Conversion happens as you type. No round-trips to a backend, no latency.
Well-Formed XML
Output is properly indented, includes a root element, and handles special characters with escaping.
Related JSON tools
Common questions answered
Is the JSON to XML converter free?
Yes, completely free with no account or signup required. The converter runs entirely in your browser.
How does the converter handle nested JSON objects in XML?
Each nested JSON object becomes a child XML element. Object keys map to element tag names, and primitive values become text content inside those elements, producing well-formed hierarchical XML.
Does the converter add a root element to the XML output?
Yes. Since XML requires a single root element, the converter wraps the output in a <root> element automatically if the top-level JSON value is an object or array.
How are JSON arrays converted to XML?
Each item in a JSON array becomes a repeated XML element with the same tag name (e.g., <item>). This preserves the ordered nature of the array in the XML output.
Is my data sent to a server during conversion?
No. All conversion runs entirely in your browser using JavaScript. Your JSON is never uploaded or transmitted to any server.
What is XML?
XML (Extensible Markup Language) is a markup language for encoding structured documents. While JSON has largely replaced XML for web APIs, XML remains dominant in enterprise systems (SOAP), document formats (XHTML, SVG, RSS), configuration files (Maven, Android manifests), and industries with established standards (healthcare HL7, finance FIX/FpML).
Converting JSON to XML maps JSON types to XML elements. Objects become parent elements with child elements for each key, arrays become repeated elements, and primitives become text content. This tool generates well-formed XML with proper indentation. Since XML has features JSON lacks (attributes, namespaces), the converter uses element-only mapping by default.
{
"user": {
"name": "Alice",
"age": 30,
"roles": ["admin", "editor"]
}
}
<?xml version="1.0"?>
<user>
<name>Alice</name>
<age>30</age>
<roles>
<item>admin</item>
<item>editor</item>
</roles>
</user>
Get the most out of this tool
- XML requires a single root element — if your JSON is an array, the converter wraps it in a root element automatically.
- JSON null values are represented as empty XML elements: <field/> or <field></field>.
- Use this converter when integrating with SOAP APIs, Android development, or any system that requires XML input.
Converting JSON to XML in depth
XML (Extensible Markup Language) and JSON are both general-purpose data serialization formats, but with very different design philosophies. XML was designed for document representation with rich metadata support: attributes, namespaces, schemas (XSD), transformations (XSLT), and queries (XPath). JSON was designed for lightweight data interchange in JavaScript environments. Many enterprise systems, legacy APIs, and industry standards (healthcare HL7, finance FIX, government SOAP APIs) use XML exclusively, making JSON-to-XML conversion a common need.
The structural mapping from JSON to XML follows clear conventions. JSON objects become XML elements with child elements for each key-value pair. The object key becomes the tag name, and the value becomes the element content or further nested elements. JSON arrays are the trickiest part — XML has no direct array concept. The most common convention is to repeat the element tag for each array element, wrapping them in a container element named after the array key.
JSON key names must be valid XML element names. XML element names cannot start with a number, cannot contain spaces, and cannot use certain characters like ampersands or angle brackets. JSON keys that start with digits (like "123field") or contain spaces ("full name") are not directly usable as XML element names. The converter sanitizes these by prefixing with an underscore or replacing invalid characters.
XML has the concept of attributes — short metadata values attached to elements using the syntax <element attribute="value">. JSON has no equivalent; all values are children. Some JSON-to-XML conventions use a prefix like @ to indicate a JSON property that should become an XML attribute rather than a child element. Without explicit guidance, the converter wraps all values as child elements — the safest default that loses no information.
Character encoding in XML requires special handling. The five reserved XML characters — ampersand (&), less-than (<), greater-than (>), quote ("), and apostrophe (') — must be escaped in text content and attribute values. The converter applies these escapes automatically, ensuring the XML output is well-formed even when JSON string values contain special characters.
SOAP web services, which underpin much of enterprise software integration, use XML envelopes for all requests and responses. REST APIs that need to interoperate with SOAP services sometimes receive JSON from mobile clients and must convert to XML before forwarding to the legacy backend. This converter can serve as a quick tool for understanding and testing these transformations during integration work.
When developers use this tool
Additional frequently asked questions
Is there a standard for converting between JSON and XML?
There is no single universal standard, but several conventions exist. Badgerfish and Parker are two well-known conventions. The W3C defined a JSON-LD format for linked data. Most conversion tools including this one use a straightforward mapping: objects to elements, arrays to repeated elements, and primitives to text content.
Can I convert XML back to JSON?
Yes, using the XML to JSON converter on this site. The reverse conversion preserves structure but may differ from the original JSON if the XML had attributes or mixed content. Round-trip fidelity depends on the specific XML conventions used during the JSON-to-XML conversion.
What XML declaration and namespace options does the output include?
The converter produces well-formed XML with an optional XML declaration (<?xml version="1.0" encoding="UTF-8"?>). No namespace declarations are added by default since namespaces are schema-specific and cannot be inferred from JSON alone. You can add the namespace declarations manually after converting.
How are JSON null values represented in XML?
JSON null has no direct XML equivalent. The most common representations are an empty element (<field/>), an element with an xsi:nil="true" attribute (using XML Schema Instance namespace), or simply omitting the element. The converter uses empty self-closing elements for null values by default.