JSON to XML converter
Convert JSON data to XML format
Every JSON key becomes an element name and every value becomes that element content. If your document has exactly one top-level key, it is promoted to the root element; otherwise the whole structure is wrapped in a root tag so the output is well formed. Arrays repeat the parent tag once per item, nested objects nest elements two spaces deeper, and null becomes a self-closing tag. The file opens with a UTF-8 XML declaration. Nothing becomes an attribute: this writer produces an element-only document.
Key facts about JSON to XML converter
| Root element | A single top-level key becomes the root. Anything else, including an array, is wrapped in a tag named root. |
|---|---|
| Arrays | Each item is written as another element with the same name, so a list of three tags produces three tag elements. |
| Attributes | None are produced. Every key becomes a child element, whatever it was called in the source. |
| Key sanitising | Any character outside letters, digits, underscore and hyphen becomes an underscore, so first name becomes first_name. |
| Nulls | Written as a self-closing element such as <note/>, which is how most XML consumers signal an empty value. |
| Escaping | Ampersand, less-than, greater-than and double quote are escaped in text. The apostrophe is left as a literal. |
| Indentation | Two spaces per level, with each element on its own line, so the result is readable without a formatter. |
| Declaration | The output starts with an XML declaration naming version 1.0 and UTF-8, and no DOCTYPE is written. |
| Numbers and booleans | Serialised as their plain text form, so a consumer has to know the schema to type them back. |
| Namespaces | Not emitted. If the destination expects a namespaced document, add the declarations to the root by hand. |
| Modes | Paste and convert, or upload a .json file, with a copy button and character counts on both panels. |
| Invalid input | Strict JSON only. Trailing commas, comments and unquoted keys stop the conversion with a parse error. |
What happens to your file
The conversion happens where you are sitting. Pasted JSON stays inside the input panel of this page, and an uploaded file is read locally with the File API before the browser own JSON parser turns it into a value. The XML is then built up as a string by a recursive writer running in this tab and offered as clipboard text or as a Blob download. No request carries your document anywhere, and nothing is retained once the tool is reset or the tab closed.
About this tool
- 1
Select paste or upload
Paste and convert is open by default; switch to file upload to convert a .json document from disk.
- 2
Consider the root
Wrap your data in a single named key if you want a meaningful root element instead of the generic root tag.
- 3
Convert
The writer walks the value, emitting an element per key and repeating tags for array items, indented two spaces.
- 4
Add what XML needs
If the target system expects a namespace, a schema location or a DOCTYPE, add those to the root element yourself.
- 5
Copy or download
Copy the markup to the clipboard, or save an .xml file when you converted from an uploaded document.
| Input and output | Takes .json (application/json) and returns the XML as a blob with the application/xml type, named after the file you dropped in. |
|---|---|
| Engine | JSON.parse reads the file and a small string builder in the page writes the elements, escaping &, <, > and quotes as it goes - nothing is fetched to do it. |
| Modes | Both modes: paste the JSON in and copy the XML straight back out, or hand over a file and take the XML as a download. |
| Batch and caps | Twenty JSON files per run at 500 MB each; several XML results are zipped in page memory as converted-xml-files.zip. |
| Browser and device | JSON to XML needs only the File API, a Blob download and the parser already in the bundle, so every current browser behaves the same and the page keeps working with the network off. |
- Rename keys before converting rather than after. Spaces, dots, slashes and the at sign all become underscores, and fixing that in the XML afterwards means editing both the opening and the closing tag.
- A key that starts with a digit produces an element name that is technically invalid XML, so rename such keys at the source if a strict validator will read the output.
- If a list must appear even when it has one item, remember that a JSON array of one still emits one element, which is indistinguishable from a single value to the consumer.
- The apostrophe is left unescaped in text content, which is valid XML, but a downstream tool that parses attributes naively may still trip on it.
- Converting JSON that came from the XML to JSON tool will not restore the original document, because the @attributes container becomes an element rather than real attributes.
- Feed a legacy system, an enterprise integration bus or a SOAP endpoint that accepts only XML, starting from a modern JSON payload.
- Produce a quick XML fixture for testing a parser or an XSLT stylesheet without hand-writing the markup.
- Hand configuration data to a tool whose reader predates JSON, such as an older build or reporting system.
Related tools
View allNeed the opposite? Try XML to JSON
Works well with this4
Other JSON tools12
Updated