How to Convert JSON to XML

Many legacy systems, SOAP APIs, and enterprise tools still speak XML. Converting JSON to XML (and back) bridges modern and legacy stacks.

How the mapping works

A JSON object becomes XML elements, where each key is a tag:

{ "user": { "name": "Alice", "age": 30 } }

becomes

<user>
  <name>Alice</name>
  <age>30</age>
</user>

Arrays

A JSON array becomes repeated elements with the same tag name:

{ "tags": ["a", "b"] }
<tags>a</tags>
<tags>b</tags>

The mismatch challenges

JSON and XML aren't perfectly equivalent:

  • Attributes — XML has them (<user id="1">), JSON doesn't. Converters often use a convention like @id.
  • Order — XML cares about element order; JSON objects technically don't.
  • Text + children — XML elements can have both; JSON needs a convention (e.g. #text).

JSON vs XML

Wondering which to use in the first place? See JSON vs XML.

Convert online

Paste JSON or XML into the JSON to XML converter to transform it in either direction, instantly and locally.

Got a config file to check?

Open the config toolkit →