What Is This Tool?
XML and JSON are both tree-shaped data formats, but they show up in different places: legacy enterprise APIs, SOAP services, RSS/Atom feeds and many config formats still speak XML, while modern REST APIs and JavaScript code speak JSON almost exclusively. This tool translates between the two so you don't have to hand-write either one when integrating old and new systems.
The conversion is built directly on the browser's DOMParser API for reading XML, and follows the structure defined by the W3C XML 1.0 specification for producing it — so the XML it generates is well-formed and the XML it accepts is parsed the same way a browser or any standards-compliant XML library would parse it.
Because XML has concepts JSON doesn't (attributes, mixed text/element content, a mandatory single root element) and JSON has concepts XML doesn't (native arrays, booleans, numbers), the tool uses a documented, widely-used convention: an XML attribute `name="value"` becomes the JSON key `"@_name": "value"`, element text content becomes either the element's direct string value (when it has no children or attributes) or a `"#text"` key alongside any attributes, and repeated sibling elements with the same tag become a JSON array.
Why Use It?
- Bidirectional — convert JSON to XML or XML to JSON from the same screen.
- Handles nesting correctly — nested JSON objects become nested XML elements and vice versa, at any depth.
- Arrays map to repeated elements — a JSON array under a key becomes that many sibling XML elements with the same tag, and repeated XML tags come back as a JSON array.
- XML attributes are preserved — using the `@_attributeName` convention, so attribute data isn't silently dropped.
- Copy to clipboard or download as a .json or .xml file.
- 100% client-side — nothing you paste is uploaded anywhere.
How to Use
- Choose a direction: "XML → JSON" or "JSON → XML".
- Paste your data into the input box.
- Click "Convert".
- Review the result, then copy it or click "Download" to save a file.
Example
Input
{"user":{"name":"Alice","age":30}}Output
<?xml version="1.0" encoding="UTF-8"?>
<user>
<name>Alice</name>
<age>30</age>
</user>The single top-level JSON key ("user") becomes the XML root element; if the JSON has more than one top-level key, the tool wraps everything in a <root> element since XML requires exactly one root.
Practical tips
- Migrating a legacy XML config (like an old app's settings file) to a modern JSON-based system: paste the XML, convert, and adjust field names as needed.
- Testing a SOAP or XML-RPC endpoint from JavaScript: convert your JSON request payload to XML here before sending it, or convert an XML response back to JSON to inspect it easily.
- If your JSON uses arrays for data that XML would represent as repeated elements, make sure the array is nested under a single key first (e.g. {"items":{"item":[1,2,3]}}) rather than a bare top-level array, since XML can't have multiple root elements.
Why the @_ attribute convention matters
The trickiest part of JSON/XML conversion is that XML elements can carry two kinds of data at once — attributes and child content — while a plain JSON object just has keys and values. Without a convention to keep these separate, a naive converter would either lose attributes entirely or mix them in with child elements in a way that can't be reliably converted back. The `@_name` prefix convention (also used by widely adopted libraries in the JavaScript ecosystem) solves this by giving attributes a distinct, unambiguous key shape, so `<product id="42">Widget</product>` round-trips cleanly as `{"product":{"@_id":"42","#text":"Widget"}}` instead of losing the id or guessing incorrectly which value was which.
Frequently Asked Questions
What happens to JSON with more than one top-level key?
XML requires a single root element, so if your JSON object has multiple top-level keys (e.g. {"a":1,"b":2}), the output is wrapped in a <root> element: <root><a>1</a><b>2</b></root>. If your JSON has exactly one top-level key, that key becomes the root element name directly.
How are XML attributes represented in JSON?
An attribute like <user id="7"> becomes the key "@_id": "7" in the resulting JSON object. This is a common, documented convention (used by libraries like fast-xml-parser) that keeps attributes distinguishable from child elements.
Do repeated XML elements become a JSON array?
Yes. If an element has multiple children with the same tag name, e.g. <items><item>1</item><item>2</item></items>, converting to JSON produces {"items":{"item":["1","2"]}}. Converting that JSON back to XML reproduces the repeated <item> elements.
Are numbers and booleans preserved when converting XML to JSON?
XML has no native concept of numbers or booleans — everything is text — so text content comes through as a JSON string (e.g. "30" rather than 30). If you need numeric types, you'll need to convert those fields afterward.
Is my data uploaded anywhere?
No. Parsing and conversion happen entirely in JavaScript in your browser, using the built-in DOMParser API — nothing is sent to a server, so it's safe to use with private configuration files or internal API payloads.