Bridge old and new data formats
XML is still everywhere: RSS and Atom feeds, sitemaps, SOAP APIs, Office files, bank exports, e-invoicing, Android layouts and many enterprise systems. Modern code and APIs prefer JSON. This XML to JSON converter translates between them in both directions with predictable rules.
Conversion rules
XML has features JSON doesn’t – attributes, mixed text and repeated elements – so the tool uses a widely used convention:
- Elements become keys.
- Attributes become keys prefixed with @.
- Text inside an element with attributes or children becomes #text; simple elements with only text become plain values.
- Repeated elements with the same name become arrays.
Example:
<order id="1042">
<item sku="A1">Notebook</item>
<item sku="B7">Pen</item>
<paid>true</paid>
</order>
becomes
{
"order": {
"@id": "1042",
"item": [
{ "@sku": "A1", "#text": "Notebook" },
{ "@sku": "B7", "#text": "Pen" }
],
"paid": true
}
}
The status line reminds you: keys starting with @ become attributes; #text becomes element text.
Convert numbers and true/false
XML has no data types – everything is text. Tick Convert numbers and true/false to turn values like 1042 and true into JSON numbers and booleans. Leave it off when values such as IDs or postcodes have leading zeros you need to keep.
JSON → XML
Choose JSON → XML and paste JSON. The same rules apply in reverse: @ keys become attributes, #text becomes text and arrays become repeated elements. XML needs exactly one root element. If your JSON has a single top-level key, that key becomes the root; otherwise the output is wrapped in the element named in Root element (JSON → XML) (default root) – useful when the JSON is an array or has several top-level keys. Special characters such as & and < are escaped automatically.
Fixing invalid XML
If the input isn’t well-formed, the tool shows Invalid XML: with the parser’s message. Common causes:
- A missing or misspelled closing tag (
<Name>…</name>– XML is case-sensitive). - An unescaped
&– write&. - Text before the root element or two root elements.
- A copy-paste that cut off the end of the document.
Round trips
Because the same conventions are used in both directions, you can convert XML to JSON, edit it in your code or editor, and convert it back. Comments, processing instructions and the original whitespace are not preserved, and the element order inside a parent may be grouped by name, so compare the result with the original if an exact layout matters – for example for files that are validated against a strict XSD schema.
Large documents
Feeds and exports of several megabytes convert in a moment on most devices. For very large files, paste only the part you need, or split the file first.
Common uses
- Reading RSS feeds or sitemaps in JavaScript.
- Converting SOAP or legacy API responses for a modern frontend.
- Inspecting XML exports from accounting or e-commerce systems.
- Generating XML config from JSON.
- Converting product feeds between platforms.
Related tools
Use CSV to JSON for spreadsheet data, Excel to CSV for workbooks, and Base64 Encode / Decode for embedded binary data, which is common inside XML.
Privacy
Everything runs in your browser using its built-in XML parser. Your data is not uploaded.
Frequently asked questions
How are XML attributes represented in JSON?
Attributes become keys starting with @, for example <item id="7"> becomes {"item": {"@id": "7"}}. Element text alongside attributes or children is stored under #text.
What happens to repeated elements?
Repeated child elements with the same name become a JSON array, so a list of <item> elements turns into "item": [ ... ].
Can I convert JSON back to XML?
Yes. Choose JSON → XML. Keys starting with @ become attributes and #text becomes element text. Set the Root element name to wrap the output.
Why does it say Invalid XML?
The XML isn't well-formed – often a missing closing tag, an unescaped & character or mismatched case. The error message tells you what the parser found.
Are namespaces supported?
Element and attribute names keep their prefixes, such as soap:Body, so namespaced XML converts predictably.
Is my data uploaded?
No. Conversion uses your browser's built-in XML parser.