How to use the JSON to XML
- Paste JSON or open a
.jsonfile. - Set the root element name and how arrays and attributes are written.
- Copy or download the XML.
Mapping JSON to XML
JSON and XML model data differently, so a converter has to follow conventions. This tool uses the most common ones (also used by libraries such as xml2js and fast-xml-parser), which makes it the exact inverse of our XML to JSON converter:
| JSON | XML |
|---|---|
{"name": "Ada"} | <name>Ada</name> |
{"tag": ["a", "b"]} | <tag>a</tag><tag>b</tag> |
{"@id": "7"} | attribute id="7" on the parent element |
{"#text": "hi"} | text content next to attributes |
null | empty element <x/> or xsi:nil="true" |
The root element
XML documents need exactly one root. If your JSON is an object with a single key, that key becomes the root. Otherwise — or if you tick Always wrap in root — everything is wrapped in the root element you choose, and top-level arrays become repeated <item> elements.
Names and escaping
XML element names cannot start with a digit or contain spaces, so keys like 2fa enabled become _2fa_enabled. Text and attribute values are escaped (& → &, < → <), so the output is always well-formed. Format the result further with the XML formatter.
Tools that pair well with the JSON to XML
- JSON to YAML — Paste JSON and get clean YAML for Kubernetes manifests, Docker Compose, GitHub Actions or any config file.
- JSON Viewer — Explore big or deeply nested JSON comfortably: fold and unfold objects, search for keys or values and click any node to get its JSONPath.
- YAML to JSON — Paste YAML — a Compose file, Kubernetes manifest or CI config — and get formatted JSON.
- JSON to CSV — Turn a JSON array into a spreadsheet-ready CSV.
Frequently asked questions
How are JSON arrays converted to XML?
{"tag": ["a","b"]} → two <tag> elements.How do I create XML attributes?
{"product": {"@id": "7", "name": "Keyboard"}} → <product id="7">.