JSON to XML Converter
Paste JSON on the left and valid XML appears on the right instantly — objects become elements, arrays become repeated elements, and @-prefixed keys become attributes.
Options
Everything runs in your browser — your JSON is never uploaded. Keys starting with @ become attributes; a #text key sets element text.
How it works
- Paste or type your JSON into the left box. The XML output updates live on the right; syntax errors are reported immediately with the position of the problem.
- Adjust the output with the indent selector (2 spaces, 4 spaces, tabs, or minified) and toggle the XML declaration. Open Options to rename the root element and the array item element.
- Click Copy XML to put the result on your clipboard, or Download .xml to save it as a file.
Frequently asked questions
- How are JSON arrays converted to XML?
- An array under a key becomes repeated elements with that key’s name, which is the convention most XML consumers expect: {"book": [1, 2]} becomes <book>1</book><book>2</book>. A top-level array is wrapped in the root element with each entry emitted using the configurable item name, and nested arrays are wrapped the same way so no structure is lost.
- Can I create XML attributes from JSON?
- Yes. Any key that starts with @ inside an object is emitted as an attribute on the parent element rather than a child element, so {"user": {"@id": "7", "name": "Ana"}} becomes <user id="7"><name>Ana</name></user>. A key named #text sets the element’s text content, which lets you combine attributes and text on the same element.
- What happens to JSON keys that are not valid XML element names?
- XML names cannot start with a digit or contain characters like spaces, slashes, or colons in arbitrary positions. This converter sanitizes such keys automatically: invalid characters are replaced with underscores and names starting with a digit get a leading underscore, so "2nd item" becomes "_2nd_item". The output is therefore always well-formed XML that any parser accepts.
- Is my JSON uploaded to a server?
- No. Parsing and conversion happen entirely in your browser with JavaScript — there are no network requests, which you can confirm in your browser’s developer tools. That makes the tool safe for API responses, configuration files, and other data that contains internal URLs, identifiers, or credentials you would not want in a third-party server log.
- Are special characters like < and & escaped correctly?
- Yes. Text content escapes &, <, and > to their entity forms, and attribute values additionally escape double quotes, so any string value round-trips safely. Numbers, booleans, and strings are written as element text, null values become empty self-closing elements, and the optional declaration marks the document as UTF-8.
About this tool
This tool converts JSON documents to well-formed XML directly in your browser. Paste any valid JSON — an API response, a configuration file, an export from a database — and the XML equivalent renders live as you type. If the JSON is malformed, you get an immediate error message with the line and position of the mistake instead of silent failure, which makes the converter double as a quick JSON validator.
The mapping follows the conventions most schemas and legacy systems expect. Object keys become element names, arrays become repeated sibling elements named after their key, and primitive values become element text with &, <, >, and quotes properly escaped. Two special prefixes give you control over structure: keys starting with @ turn into attributes on the parent element, and a #text key sets an element’s text content so attributes and text can coexist. Keys that are not legal XML names are sanitized with underscores, and null values are written as self-closing empty elements. Everything runs client-side with no network requests, so sensitive payloads never leave your machine.
Typical uses include preparing data for SOAP services and older enterprise APIs that only speak XML, generating RSS-like or sitemap-like documents from JSON sources, converting REST API responses for tools that ingest XML, and producing test fixtures for XML parsers. The configurable root element and array item names help you match an existing schema without post-editing.
A few practical tips: choose tab or 4-space indentation when the output will be read by humans, and minified when it will be sent over the wire. If a downstream system rejects the file, check whether it requires a specific root element name — you can set it under Options. And remember that JSON key order is preserved in the output, so ordering-sensitive schemas convert predictably.