Converters
JSON to XML Converter
Turn a JSON structure into XML.
JSON0 chars
XML
Guide & explanation
The JSON to XML Converter maps a JSON structure onto XML elements.
Mapping rules
| JSON | XML |
|---|---|
| Object | Nested elements; the key becomes the element name |
Array {"a":[1,2]} | <a>1</a><a>2</a> (repeated elements) |
| String / number / boolean | Element text |
null, empty object, empty string | Empty element <x/> |
| Empty array | Omitted |
Example
{ "user": { "id": 1, "roles": ["admin", "editor"] } }
<root>
<user>
<id>1</id>
<roles>admin</roles>
<roles>editor</roles>
</user>
</root>
Options & notes
- Root and Array item — the wrapping element names.
- XML declaration — insert
<?xml version="1.0"?>. - Keys that are not valid XML element names (spaces,
@, leading digit) are adjusted automatically and reported.