JSON to XML

Instant conversion

Paste any JSON object or array and get well-formed, indented XML output. Arrays are expanded as repeated elements. Null values become self-closing tags. Runs entirely in your browser — no data is sent to any server.

JSON input
XML output

Output will appear here

Conversion rules

  • JSON objects Each key becomes an XML element. Nested objects create nested elements.
  • JSON arrays Each array item becomes a repeated element with the same tag name as the parent key.
  • Null values JSON null becomes a self-closing XML element: <tagName />.
  • Root element The top-level JSON object is wrapped in a <root> element by default.
  • Special characters Characters like <, >, &, " are escaped in the XML output.

Common use cases

  • Preparing data for payment APIs that accept XML format rather than JSON
  • Converting configuration objects to XML for legacy enterprise systems
  • Transforming data structures when integrating with ISO 20022 messaging workflows
  • Quick prototyping of XML payloads before building a full serializer

Dev snippet — JSON to XML (Node.js)

function jsonToXml(obj, indent = 0) {
  const pad = "  ".repeat(indent);
  return Object.entries(obj).map(([key, val]) => {
    if (val === null) return `${pad}<${key} />`;
    if (Array.isArray(val))
      return val.map(item => `${pad}<${key}>${jsonToXml(item, indent + 1)}${pad}</${key}>`).join("\n");
    if (typeof val === "object")
      return `${pad}<${key}>\n${jsonToXml(val, indent + 1)}${pad}</${key}>`;
    return `${pad}<${key}>${val}</${key}>`;
  }).join("\n");
}

const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<root>\n${jsonToXml(yourObject, 1)}\n</root>`;