JSON has won the API world, but XML is far from dead. If you are talking to a SOAP service, generating an RSS feed, feeding a legacy enterprise system, or writing a config file in an XML format, you still need to turn your JSON into clean, well-formed XML. This guide shows how to convert JSON to XML and how the two structures map onto each other.
When you still need XML
JSON is the default for modern REST APIs, but plenty of systems expect XML and nothing else:
- SOAP APIs. The envelope, body, and every payload are XML by definition.
- RSS and Atom feeds. Feed readers parse XML, so a JSON feed has to be reshaped.
- Legacy and enterprise systems. Banking, healthcare, and government integrations often predate JSON and still mandate XML schemas.
- Config formats. Some build tools and Java or .NET apps read XML configuration files.
When the receiving end is fixed, your JSON has to become valid XML before it will go through.
How JSON maps to XML
The conversion follows a few consistent rules. Object keys become elements, and arrays become repeated elements. So this JSON:
{
"user": {
"name": "Ada",
"roles": ["admin", "editor"]
}
}
becomes this XML:
<root>
<user>
<name>Ada</name>
<roles>admin</roles>
<roles>editor</roles>
</user>
</root>
Two things are worth noting. First, XML requires a single root element, so the converter wraps everything in one wrapping tag (here <root>). JSON allows a top-level array or value with no name, but XML does not, so a root is always added. Second, JSON has no native concept of attributes. Everything in JSON is a key and a value, so by default every key becomes a child element rather than an attribute like id="1".
Convert JSON to XML in three steps
- Open the JSON to XML Converter and paste your JSON or drop in a file.
- Confirm the root element name and review how nested objects and arrays are nested in the output.
- Click Convert, check the XML, then Copy or download the result.
Everything runs on your device. Your JSON is never uploaded, which matters when it holds tokens, customer records, or anything you would not paste into a random website.
Watch out for invalid element names
The biggest source of broken output is element names, because XML is stricter than JSON about what a name can be. A JSON key can be almost any string, but an XML element name cannot start with a digit and cannot contain spaces.
- Keys with spaces. A key like
"first name"is not a valid element name. Replace the space with an underscore or hyphen first. - Keys that start with a digit. A key like
"2024"is invalid as<2024>. Prefix it with a letter or underscore. - Reserved characters. Values containing
<,>, or&are escaped automatically so the XML stays well-formed.
If your XML will not parse, scan your JSON keys for spaces and leading numbers first. The JSON to XML Converter flags the structure so you can spot these before they cause errors downstream.
Related tools
- Going the other direction? Use XML to JSON to turn elements back into objects.
- Want to clean up the JSON first? Beautify or validate it with the JSON Formatter.
- Working with YAML config too? Convert it with the YAML to JSON Converter.
Paste your JSON, set a root, convert, and copy well-formed XML in seconds.