Developer

JSON to XML Converter — Free Online 2026

JSON to XML converter transforms your JSON data into valid, well-formed XML instantly. Objects become elements, arrays become repeated child elements, and special keys become attributes. Configure the root element name and attribute prefix below — no sign-up needed.

How It Works

  1. Set root element name and attribute prefix
  2. Paste JSON into the input panel
  3. Converted XML appears on the right automatically
  4. Copy the valid XML to use in your application

JSON to XML — Conversion Rules and Use Cases

Converting JSON to XML requires a mapping convention because the two formats have different structural semantics. In this converter, JSON object keys become XML element names, and their values become the element content. If a key starts with the attribute prefix (default @), it becomes an XML attribute on the parent element instead of a child element. JSON arrays are unrolled into repeated child elements — a JSON array under key books becomes multiple <item> children of a <books> element. Null values produce self-closing elements. Special XML characters in text content and attribute values (&, <, >, ", ') are automatically escaped. Use the reverse converter at XML to JSON to go the other direction. Before converting, you can explore the JSON structure with the JSONPath Finder.

XML Attributes vs Child Elements

XML has two ways to attach data to an element: attributes (inside the opening tag) and child elements. This converter treats any JSON key prefixed with @ as an attribute. For example, {"@id": "42", "name": "Jane"} converts to <item id="42"><name>Jane</name></item>. This convention follows the BadgerFish and Parker conventions used by many JSON/XML conversion libraries. If your target XML schema uses a different attribute marker, change the prefix in the settings above.

Common Use Cases

SOAP web services require XML request bodies — convert your JSON payload to XML to call legacy SOAP endpoints. RSS and Atom feeds are XML — use this to convert your content data to feed format. Java and .NET applications often consume XML configuration — convert JSON config to XML for these environments. XML-based data exchange formats like FHIR HL7 (healthcare), XBRL (finance), and GML (geography) all require XML input that can be generated from JSON source data.

XML Validity and Well-Formedness

This converter produces well-formed XML — every element is properly opened and closed, attribute values are quoted, and special characters are escaped. However, it does not produce XML that validates against a specific XML Schema (XSD) or DTD, because that would require you to supply the schema. If your target system requires schema-valid XML, use this tool to get the basic structure right, then adjust element names and attributes to match the XSD. The output always starts with an XML declaration (<?xml version="1.0" encoding="UTF-8"?>) for maximum compatibility.

Frequently Asked Questions

JSON objects become XML elements whose tag names are the JSON keys. Arrays become repeated elements. Primitive values become element text content. Keys starting with the attribute prefix (@) become XML attributes instead of child elements.

Valid XML documents must have exactly one root element. JSON objects and arrays at the top level have no built-in root tag name, so you need to specify one (default: root).

JSON array elements are converted to repeated XML child elements inside a parent element with the array's key name. Each array item gets an <item> tag by default.

Yes. Use the XML to JSON converter at truetools.org/tools/xml-to-json to convert in the reverse direction.

Comments