JSON to XML Converter
Convert JSON to XML instantly. Supports custom root tags and indentation for clean, structured output.
Convert JSON to XML instantly. Supports custom root tags and indentation for clean, structured output.
Converting JSON to XML is the inverse of the more common XML-to-JSON direction. The conversion is straightforward in spirit — turn each JSON object into an XML element, each key into a child tag, each value into the element's text — but XML imposes structural rules JSON does not have. Keys with special characters cannot become element names; arrays need a consistent representation; values that are objects need their own nested structure.
This converter uses a convention close to the one most XML-to-JSON tools follow: keys prefixed with @ become attributes on the parent element; a key named #text supplies the element's text content; arrays produce repeated elements with the same name. Following this convention keeps the round-trip consistent if you originally produced the JSON from XML.
Output XML is well-formed by construction: every element is properly closed, attribute values are quote-escaped, and text content is escaped for XML special characters (&, <, >). The result opens cleanly in any XML parser, validator, or tool that consumes XML.
Many established systems still expect XML even when their inputs come from modern JSON-producing pipelines. SOAP services, enterprise integrations, RSS publishers, government data submissions, and a long tail of legacy software accept XML and reject JSON. The conversion bridges modern producers to legacy consumers.
XML also supports features JSON does not have natively — namespaces, schemas (XSD), processing instructions, and a strong tradition of formal validation. For systems where these features matter (XML signatures, formally validated data exchange, complex schema constraints), generating XML output remains the right choice.
Paste JSON, get XML.
The converter walks the JSON value recursively. Objects become elements; for each key in the object, an @ prefix means the key is converted to an attribute on the parent element, # text supplies the element's text content, and ordinary keys become child elements with the value recursed into the same conversion.
Arrays are converted to repeated sibling elements. An array under key items in JSON produces one <items> element per array item in the parent. This matches how XML-to-JSON converters represent multi-element collections.
Element names that would be invalid in XML (containing spaces, special characters, or starting with digits) are sanitized: spaces become underscores, invalid characters are stripped, and digit-leading names are prefixed. Attribute and text values are XML-escaped (& becomes &, < becomes <, etc.) to keep the output well-formed.