JSON to XML Converter
Convert JSON to well-formed XML in your browser using the @attribute, #text and array convention. Set the root and item element names, validate or rename invalid keys, choose indentation, and copy or download the escaped XML.
Convert JSON to well-formed XML in your browser using the @attribute, #text and array convention. Set the root and item element names, validate or rename invalid keys, choose indentation, and copy or download the escaped XML.
JSON to XML Converter builds a well-formed XML document from JSON, using the same convention as the XML to JSON Converter. Object keys become elements; keys starting with @ become attributes; "#text" becomes the element’s text; arrays repeat their key as sibling elements; and null becomes an empty element. Strings, numbers and true/false are written as escaped text, so nothing you paste is ever treated as markup.
You set the root element name, and the element name used for root arrays and arrays nested inside arrays. If the JSON is an object with a single top-level key — the shape XML to JSON produces — that key can be used as the root. Every element and attribute name is checked against XML naming rules; invalid keys stop the conversion unless you choose to rename them, in which case the renamed keys are listed. The finished XML is re-parsed by your browser’s XML parser to confirm it is well-formed.
An array repeats its key: {"b": [1, 2]} becomes <b>1</b><b>2</b>. A root array, and an array directly inside another array, use the array item element name (item by default).
Start the key with @ for an attribute, for example "@id": "7", and use "#text" for the element’s own text. Attributes must be simple values, not objects or arrays.
XML names cannot contain spaces or most symbols and cannot start with a digit. By default the conversion stops and names the key. If you choose “Rename them”, invalid characters become _ (and a leading _ is added where needed), and every renamed key is listed.
Yes. &, < and > are escaped in text; attribute values also escape quotes, tabs and line breaks. Control characters that XML 1.0 cannot contain are reported as an error.
Keys such as dc:title are allowed when the prefix is declared with an "@xmlns:dc" key on the same or a parent object. Undeclared prefixes are reported because the result would not be valid XML.
Often, but not always. Numbers and true/false become text, null becomes an empty element, and indentation adds whitespace around mixed text, so XML and JSON do not preserve each other perfectly.
Up to 5 MB of JSON with 100 levels of nesting, and up to 20 MB of generated XML.
No. Pasted text and opened files are processed in your browser on your device. Nothing is uploaded, and data, settings and results are not saved in browser storage. Reset clears them from the page.