XML to JSON with a loss report

Pick a mapping profile, preview the JSON, and read exactly what the conversion could not carry across.

Mapping profile

JSON (derived copy)

Lossy — see report
{
  "order": {
    "@xmlns": "urn:example:orders:v2",
    "@xmlns:addr": "urn:example:address",
    "@id": "SO-10442",
    "@status": "confirmed",
    "@created": "2026-10-30T09:12:00Z",
    "customer": {
      "@ref": "C-221",
      "name": "Asha Rao",
      "addr:postal": {
        "@country": "IN",
        "addr:line": "14 Lake View Road",
        "addr:city": "Pune"
      }
    },
    "lines": {
      "line": [
        {
          "@sku": "KB-87",
          "@qty": "2",
          "@unit": "EUR",
          "#text": "49.90"
        },
        {
          "@sku": "MS-03",
          "@qty": "1",
          "@unit": "EUR",
          "#text": "19.00"
        }
      ]
    },
    "note": {
      "em": "reception",
      "#text": "Leave with  if nobody answers.  Fragile!"
    },
    "instructions": {
      "@xml:space": "preserve",
      "#text": "\n  Gate code:   4471\n  Ring twice.\n"
    },
    "empty-flag": ""
  }
}

Loss report (5)

What is lostCountExamples
Comments are not represented.1(prolog/epilog)
The XML declaration is not represented.1
All values are strings; no number/boolean typing is inferred.1
Names are written as prefix:local strings. Namespace identity depends on the copied xmlns keys, not on the JSON structure.13order, customer, name, addr:postal, addr:line
Mixed content: text and child elements were separated, so their relative order is lost.1/order/note

Two mapping profiles

Ordered (bxml-ordered/1) writes every node — elements, text, CDATA, comments, processing instructions — as an array in document order, with namespace URIs on each name. It converts back to equivalent XML. Only lexical details are lost, such as quote style and how characters were escaped.

Compact (bxml-compact/1) is the familiar shape: attributes as "@name", text as "#text", repeated elements as arrays. It is never labelled lossless. Mixed content loses its order, comments and processing instructions disappear, CDATA becomes plain text, everything is a string, and a name can be a single object in one place and an array in another. Each of these is counted in the loss report with examples.

Questions

Why are numbers strings?

XML text has no type without a schema. Guessing would turn ZIP codes like 01234 into 1234, so the compact profile keeps strings.

Can I go back to XML?

Yes, on the JSON to XML page. JSON in the ordered profile converts back exactly; compact JSON follows documented rules.