Главная JSON to XML

JSON to XML

Convert JSON to formatted XML instantly — custom root element, proper escaping, 100% in your browser.

Input

Output

Original
Result
Type

What is JSON to XML conversion?

JSON to XML conversion transforms a JSON object into an XML document. Each key in the JSON object becomes an XML element, with nested objects and arrays becoming child elements. The converter produces well-formed XML with proper indentation, escaping, and an XML declaration.

You can specify a custom root element name (default is "root"). Since JSON objects don't have a natural root element like XML does, the converter wraps the entire JSON object in a root element with the name you provide. This ensures the resulting XML has exactly one root element, as required by the XML specification.

JSON vs XML structure

JSON and XML have different structural models. JSON has objects (key-value pairs) and arrays (ordered lists), while XML has elements (with tags), attributes, and text content. The converter maps JSON objects to XML elements: each key becomes a tag name, and the value becomes the element's content.

Arrays in JSON are converted to repeated XML elements with the same tag name. For example, {"items":["a","b"]} becomes <items>a</items><items>b</items>. This is the most natural mapping, though it means array items lose their positional information in the XML output.

When to convert JSON to XML

Converting JSON to XML is useful in several scenarios:

  • Legacy system integration. Send JSON data to SOAP services or legacy systems that expect XML.
  • Configuration generation. Generate XML configuration files from JSON data.
  • Data exchange. Share JSON data with systems or applications that only support XML.
  • Document generation. Create XML documents (like SVG, RSS, or Office Open XML) from JSON data structures.
  • Testing and mocking. Generate XML test fixtures or mock responses from JSON data.

How to convert JSON to XML

Converting JSON to XML with this tool takes a second and happens entirely in your browser. Follow these steps:

  1. Set root element name. Enter a name for the root XML element in the "Root Element Name" field. The default is "root".
  2. Paste your JSON. Enter a JSON object in the input box. The object's keys will become XML element names.
  3. Click "Convert" and copy. The XML output appears in the output box, complete with an XML declaration and proper indentation.

The output includes an <?xml version="1.0" encoding="UTF-8"?> declaration and uses 2-space indentation for readability.

How the conversion works

The converter recursively walks the JSON object. For each key-value pair, it creates an XML element with the key as the tag name. Object values become nested elements, array values become repeated elements, and primitive values (strings, numbers, booleans) become text content. All text content is properly XML-escaped: &, <, >, ", and ' are replaced with their entity references.

Note that JSON keys must be valid XML element names. Keys starting with numbers, containing spaces, or using special characters may produce invalid XML. Use alphanumeric keys with underscores or hyphens for best results. Null values become empty elements, and the converter does not generate XML attributes — all data is represented as element content.

Is this JSON to XML converter free?

Yes, completely free with no sign-up, no limits beyond your device's memory, and no upload.

Can I customize the root element name?

Yes. Enter any valid XML name in the "Root Element Name" field. The default is "root".

Are JSON arrays converted to XML?

Yes. JSON arrays become repeated XML elements with the same tag name. For example, ["a","b"] becomes two elements with the same name.

Is my data uploaded?

No. All conversion is local. Your JSON data never leaves your browser.