JSON formatter / validator

XML to JSON converter

Translate XML payloads to JSON in your browser, with attributes mapped to a predictable @ prefix convention.

local only

Format pair conversion

XML to JSON conversion notes

Use this XML to JSON converter when an SOAP response, RSS feed, government data file, or legacy API gives you XML and the consuming code expects JSON. The converter walks the XML tree, turns each element into an object property, collects repeated siblings into arrays, and stores attributes under a leading @ prefix to keep them distinct from child elements. Text content lives under a #text key when an element has both attributes and inner text. The page is browser-only, so you can paste a sample response from a vendor or partner without uploading it to an external service.

Source

<order id="A-1001"><customer>Ada</customer><items><item sku="DEV-1" qty="2"/><item sku="DEV-2" qty="1"/></items></order>

Result

{
  "order": {
    "@id": "A-1001",
    "customer": "Ada",
    "items": {
      "item": [
        {"@sku": "DEV-1", "@qty": "2"},
        {"@sku": "DEV-2", "@qty": "1"}
      ]
    }
  }
}
Attribute convention
Attributes serialize under a leading @ key (configurable in many libraries)
Repeated elements
Repeated child elements collapse into a JSON array
Common pitfall
Mixed text and elements need a #text key plus child keys

Source: Extensible Markup Language (XML) 1.0 (Fifth Edition), accessed 2026-05-06

FAQ

Why are attributes prefixed with @ in the JSON output?

The @ prefix is a widely used convention (badgerfish, Spyglass, .NET XmlSerializer) for distinguishing element attributes from child elements when projecting XML into JSON.

What happens to XML namespaces?

Namespace prefixes are kept as part of the element name (for example soap:Envelope becomes the key 'soap:Envelope'), and xmlns declarations are emitted as @xmlns or @xmlns:prefix attributes.

How are repeated child elements handled?

When an element has more than one child with the same name, those children become a JSON array. With a single child, it stays a single object so the shape matches the source XML.