devtools

JSON to XML Converter

Convert JSON to clean, indented XML in your browser: objects nest, arrays repeat as elements, primitives become text, and special characters are escaped safely.

Runs entirely in your browser — your data never leaves your device.

How to use JSON to XML Converter

What it does & when you need it

Some systems still insist on XML — a legacy SOAP endpoint, an Android layout, an RSS or sitemap file, a bank integration. When your data already lives as JSON, this converter turns it into clean, indented XML wrapped in a single root element. Objects nest, arrays repeat, primitives become element text, and every unsafe character is escaped so the result is well-formed. It all happens in your browser, so nothing you paste is uploaded.

How to use

  1. Paste JSON into the input.json buffer, or press Sample to load an example object.
  2. Optionally set a Root name in the toolbar — response, config, or whatever your consumer expects. The default is root.
  3. Watch output.xml update as you type. Invalid JSON is reported in the status bar rather than producing broken markup.
  4. Press Copy XML or Ctrl/Cmd + Enter. To pretty-print the XML further or check it, try the XML Formatter.

Things worth knowing

Arrays turn into repeated tags, not a container. XML has no indexed list, so { "tag": ["a", "b"] } becomes <tag>a</tag><tag>b</tag>. There is no wrapper element per item — the repetition of the tag name is the list.

There must be exactly one root. That is why everything is wrapped. A top-level primitive becomes the root's text, and a top-level array is wrapped in the root with each entry emitted as an <item> element, because anonymous array entries have no tag name of their own.

Escaping keeps the output valid. The five metacharacters &, <, >, ", and ' are escaped to &amp;, &lt;, &gt;, &quot;, and &apos; in text. Keys that are not legal XML names — those with spaces or a leading digit — are rewritten with underscores, so a key like first name becomes first_name. Need the reverse trip? Use XML to JSON.

Examples

Nested object

{
  "user": {
    "id": 7,
    "name": "Ada"
  }
}

Nested objects become nested elements, each indented one level deeper than its parent.

Array becomes repeated tags

{
  "tags": ["alpha", "beta", "gamma"]
}

The three array entries emit three sibling <tags> elements rather than one container.

Special characters escaped

{
  "expr": "a < b && c > d",
  "quote": "she said \"hi\""
}

Angle brackets, ampersands, and quotes are escaped so the resulting XML is well-formed.

Frequently asked questions

How are JSON arrays turned into XML?

An array becomes a run of sibling elements that all share the key name: { "tag": ["a", "b"] } produces <tag>a</tag><tag>b</tag>. There is no separate wrapper element per item, because XML expresses a list as repeated tags rather than an indexed container the way JSON does.

What is the root element, and can I rename it?

XML must have exactly one root, so the whole document is wrapped in a single element named "root" by default. You can set your own root name in the toolbar — for example "response" or "config". The name is sanitised to a legal XML name if it contains spaces or other invalid characters.

How are a top-level array or a bare primitive handled?

A primitive at the top level becomes the root element's text, so 42 yields <root>42</root>. A top-level array is wrapped in the root and each item is emitted as an <item> element, since anonymous array entries have no natural tag name of their own.

Which characters are escaped, and what about invalid keys?

The five XML metacharacters &, <, >, ", and ' are escaped in text content to &amp;, &lt;, &gt;, &quot;, and &apos;. Object keys that are not valid XML element names — those with spaces or a leading digit — are rewritten with underscores so the output always parses.

Is my JSON uploaded anywhere?

No. The conversion is pure JavaScript running in your browser, so an API response or configuration object never leaves your machine, and the tool continues to work offline after the initial page load.