Loona Automation logoLoona Developer Tools
Home › Data Converters

XML to JSON Converter

In short: paste XML and get JSON: attributes become @-prefixed keys, repeated sibling elements become arrays, and element text becomes the value (numbers and booleans typed).
🔒 Private by design: everything runs in your browser on this device. Your input is never uploaded to a server.

Example

Input:

<person><name>Ali</name><age>30</age></person>

Output:

{
  "person": {
    "name": "Ali",
    "age": 30
  }
}

About this converter

This converter parses the XML with a real parser (not regex) and maps it to JSON by the standard conventions: an element with no attributes and no children becomes its text value, with obvious numbers and booleans typed; attributes are preserved as @name keys so nothing is lost; siblings sharing a tag collapse into an array under that tag; mixed content keeps its text under #text. Those conventions make the output predictable and round-trippable with this site's JSON to XML converter. Namespaces are kept literally in tag names (prefix:local), because stripping them silently is how data pipelines lose meaning.

Frequently Asked Questions

Why did a single child not become an array?

One occurrence cannot be distinguished from a lone element; arrays form from two or more same-tag siblings — the universal ambiguity of XML-to-JSON mapping.

What happens to comments and the XML declaration?

They are structural noise for data purposes and are dropped; the root element becomes the top-level key.

Related Developer Tools

Embed this tool on your website — free

Add this tool to your own website or blog — it is completely free, needs no sign-up, and always shows the latest version. Copy the code below and paste it into your page where you want the tool to appear. Keeping the small “Powered by Loona Automation” credit line under the embed helps keep this tool free — but you are free to style or remove it; the tool works either way.