JSON to XML
Convert JSON to XML live — with @attributes / #text round-tripping, safe element-name sanitisation, and configurable root, indent & declaration.
About this ToolHow it works, benefits & use casesTap to collapse
Convert a JSON document into well-formed XML, generated live as you type. Each key becomes an element and arrays expand into repeated sibling elements with the same tag, so a list of items maps naturally onto XML. The converter understands two special keys for fuller fidelity: an "@attributes" object is emitted as XML attributes on the surrounding element, and a "#text" value becomes the element's text content — the same convention the companion XML to JSON tool produces, so values round-trip between the two. Element names that are not valid XML are sanitised automatically, and text and attribute values are XML-escaped so characters like &, < and > stay safe. You can name the root element, choose 2- or 4-space indentation, and optionally prepend an XML declaration. The output reports how many elements were generated and can be copied, downloaded as .xml, or shared — all processed in your browser with nothing uploaded.
How to Use
- 1Set the root element name (defaults to root) and choose 2- or 4-space indentation.
- 2Toggle "XML declaration" on or off depending on whether you want the <?xml …?> prolog.
- 3Paste your JSON into the input panel — the XML appears live — or click "Load example" to see the @attributes and #text conventions.
- 4Press "Convert to XML" to validate the JSON.
- 5Copy the XML, download it as output.xml, or share it via the generated URL.
Key Benefits
- Maps JSON keys to elements and arrays to repeated sibling elements
- Round-trips with the XML to JSON tool via "@attributes" and "#text" keys
- Sanitises invalid element names and XML-escapes text and attribute values
- Configurable root element name and 2- or 4-space indentation
- Optional XML declaration prolog
- Live preview with an element count, plus copy, .xml download and sharing
- Runs entirely in the browser — your data is never uploaded
Common Use Cases
- Producing an XML payload for a SOAP or legacy service from JSON data
- Generating sample XML fixtures from a JSON object during testing
- Adding XML attributes to elements using the "@attributes" convention
- Converting configuration between JSON and XML representations
- Building an RSS- or sitemap-style document where arrays become repeated nodes
Options
Prepend <?xml version="1.0" encoding="UTF-8"?>
0 characters · live · "@attributes" & "#text" keys supported
Paste JSON above to see the XML live.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
- Color ConverterConvert between HEX, RGB, HSL, and HSV
- cURL to Code ConverterConvert cURL commands to code in various languages
- JSON Path FinderFind and test JSON paths
- npm to Yarn ConverterConvert npm commands and package-lock.json to Yarn equivalents
- Postman to cURL ConverterConvert Postman requests to cURL commands
- Sitemap Priority CalculatorPaste a list of URLs and get a complete XML sitemap with priorities from a transparent, tunable model — each URL auto-classified by type & depth, with a per-row score breakdown and priority distribution analysis
Put an "@attributes" object inside the JSON object for that element. For example, { "person": { "@attributes": { "id": "42" }, "name": "Jo" } } produces <person id="42"><name>Jo</name></person>. The attribute values are XML-escaped automatically.
An array becomes a set of repeated sibling elements that all share the array's key as their tag name. So { "tags": ["a", "b"] } produces two <tags> elements rather than a single wrapper with indexed children.

