JSON to XML Converter

Convert JSON to well-formed XML, with @attributes and a custom root element.

How is JSON converted to XML?

JSON to XML conversion maps each JSON property to an XML element with the same name, arrays to repeated elements and special keys to attributes, producing a valid XML document for systems that require XML.

Mapping rules

JSONXML
{"title": "SEO"}<title>SEO</title>
{"@id": "1"}attribute id="1"
{"#text": "Hi"}element text
{"tag": ["a", "b"]}<tag>a</tag><tag>b</tag>
nullempty element <tag/>

Special characters are escaped (&, <, >, quotes) and invalid element names are made safe, so the output is always well-formed. Top-level arrays are wrapped in the root element you choose.

Convert back with the XML to JSON Converter or tidy the result with the XML Formatter.

Frequently asked questions

Can I set XML attributes?

Yes — prefix the JSON key with @, for example "@id": "1".

What happens to keys with spaces?

They are converted to valid XML names by replacing invalid characters with underscores.

Is an XML declaration added?

Yes, the output starts with .