Mapping rules
| JSON | XML |
|---|---|
{"title": "SEO"} | <title>SEO</title> |
{"@id": "1"} | attribute id="1" |
{"#text": "Hi"} | element text |
{"tag": ["a", "b"]} | <tag>a</tag><tag>b</tag> |
null | empty 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 .

