JSON to XML
Convert JSON to well-formed XML online with a configurable root element and attribute support. Validate the input and download the XML file.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the JSON to XML
The JSON to XML converter produces well-formed XML from JSON, with a root element you choose. Arrays become repeated elements, which is how most XML formats represent lists.
Conversion happens in your browser, so your files and records stay private.
How to use the JSON to XML
- Paste JSON.
- Set the root element name and indentation.
- Copy or download the XML.
Example
Input
{
"order": {
"@_id": "1042",
"customer": "Ada Lovelace",
"item": [
{ "@_sku": "A-1", "#text": "Notebook" },
{ "@_sku": "B-7", "#text": "Pen" }
]
}
}Result
<?xml version="1.0" encoding="UTF-8"?>
<root>
<order id="1042">
<customer>Ada Lovelace</customer>
<item sku="A-1">Notebook</item>
<item sku="B-7">Pen</item>
</order>
</root>Keys starting with @_ become attributes, #text becomes the element’s text and the item array becomes repeated <item> elements.
Common mistakes
- An extra root element. XML allows only one root, so the whole JSON is wrapped in the root element you set (root by default). To make <order> the root, paste only the inner object and set the root name to order.
- Keys that are not valid XML names. Names cannot start with a digit or contain spaces. Such keys are adjusted to stay well-formed, so check them if a consumer expects exact names.
- Expecting a specific schema. The converter maps JSON structure to XML generically. A format with a fixed schema (SOAP, UBL, sitemaps) may need renamed elements or namespaces.
Works well with the JSON to XML
- XML to JSON: convert XML back to JSON with the same attribute convention.
- XML Validator: confirm the output is well-formed.
- XML Formatter: change the indentation of the result.
Frequently asked questions
How are invalid element names handled?
JSON keys that are not valid XML names (for example ones starting with a digit) are adjusted so the output stays well-formed.
Can I create XML attributes?
Yes. Keys that start with @_ become attributes, so { "book": { "@_id": "1" } } produces <book id="1">.
How are null values written?
As empty elements, such as <middleName/>, so the element is still present.
Are special characters escaped?
Yes. &, < and > in values are escaped, so the output is always well-formed.
Guides and tutorials
Related tools
JSON to CSV
Convert JSON arrays to CSV online with automatic column detection, nested object flattening and custom delimiters. Open the result in Excel or Sheets.
CSV to JSON
Convert CSV to a JSON array online with header detection, type inference and delimiter auto-detection. Turn spreadsheet exports into data for APIs and code.
XML to JSON
Convert XML to JSON online, keeping attributes and turning repeated elements into arrays. Malformed XML is reported with its location.
JSON to YAML
Convert JSON to clean, human-readable YAML online. Turn API responses and package files into config for Kubernetes, Docker Compose or CI pipelines.
YAML to JSON
Convert YAML documents to formatted JSON online with syntax validation. Errors are reported by line, so broken indentation is quick to find and fix.
JSON to PHP Array
Convert JSON to a PHP array literal online, using short [] or long array() syntax. Paste API responses straight into PHP code, tests and config files.