JSON to XML

Convert JSON to well-formed XML.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

JSON to XML Converter Online

The JSON to XML converter turns JSON objects and arrays into clean, well-formed XML. Paste JSON and the XML appears instantly, with your choice of root element, array item name, indentation, and XML declaration. Attributes and text nodes are supported through simple key conventions.

Conversion rules

  • Objects become elements; each key becomes a child element.
  • Arrays repeat the element for each item: {"tag": ["a", "b"]} → <tag>a</tag><tag>b</tag>.
  • Primitive values become text content. Booleans and numbers are written as-is.
  • null becomes an empty element such as <middleName/>.
  • @-keys become attributes: {"@id": "7"} → id="7".
  • #text sets the text content of an element that also has attributes.
  • Keys that aren't valid XML names are sanitized automatically.

When you need XML

JSON dominates modern web APIs, but XML is still everywhere: SOAP services, RSS and Atom feeds, sitemaps, Android resources, Maven and .NET configuration, office document formats, banking and government interfaces. Converting JSON test data or API responses into XML is the quickest way to feed these systems or build sample payloads.

Options

  • Root element – XML must have exactly one root, so the whole document is wrapped in it (default root).
  • Array item name – element name used for items of a top-level array.
  • Indentation – 2 or 4 spaces, tabs, or a single line.
  • XML declaration – adds <?xml version="1.0" encoding="UTF-8"?> at the top.

Convert JSON to other formats with JSON to YAML or JSON to CSV. To check the input first, use the JSON Validator.

Frequently Asked Questions

Each array item becomes a repeated element named after the array's key, so "book": [ {...}, {...} ] turns into two <book> elements. A top-level array uses the “Array item name” setting (item by default) inside the root element.

Yes. Keys starting with @ become attributes of their element ("@id": "bk101" → id="bk101"), and a "#text" key sets the element's text content. This is the same convention many XML-to-JSON converters use, so round trips work.

XML names can't contain spaces or most punctuation and can't start with a digit. Invalid characters are replaced by underscores and names starting with a digit get a leading underscore, so "first name" becomes <first_name> and "2024" becomes <_2024>.

The characters &, <, >, and " in values are escaped as &amp;, &lt;, &gt;, and &quot;, so the output is always well-formed XML. null values become empty elements like <note/>.