JSON to XML
Convert JSON to XML online. Handles nested objects, arrays, @attributes, and #text fields. Configurable root element, indentation, and XML declaration.
Convert JSON objects and arrays to well-formed XML. Nested objects become child elements,
arrays become repeated elements with the same tag, and
@attributes
objects are converted to XML attributes. The output includes an optional XML declaration
and configurable indentation.
Related tools
Frequently asked questions
How are JSON arrays converted to XML?
JSON arrays become repeated XML elements with the same tag name. For example,
{"{ 'books': [{ 'title': 'A' }, { 'title': 'B' }] }"}
becomes two <books> elements each containing a
<title> child.
How do I add XML attributes?
Add an @attributes object inside any element object.
For example: {"{ 'book': { '@attributes': { 'id': '1' }, 'title': 'Dune' } }"}
produces <book id="1"><title>Dune</title></book>.
When is the root element name used?
If your JSON has a single top-level key, that key becomes the root element name (the "Root element" field is ignored). If your JSON has multiple top-level keys or is an array, they are wrapped in the configured root element. This matches the most common JSON structure where a single wrapper object represents the document root.
Are special XML characters escaped automatically?
Yes. All string values and attribute values are escaped before being written to XML.
Characters that would break XML syntax — &,
<,
>,
",
' —
are converted to XML entities automatically.
What happens to JSON null values?
JSON null values are converted to
self-closing empty elements: <fieldName/>.
This is the most common convention for representing absent values in XML, analogous to
xsi:nil in XML Schema.