DataHub Tools XML to JSON

XML to JSON Converter

Local-first

Convert XML documents into readable JSON objects locally in your browser.

What is XML to JSON?

Convert XML documents into readable JSON objects locally in your browser.

    How to use it

    1. Paste one well-formed XML document with a single root element.
    2. Convert and check attributes under @attributes and element text under #text when applicable.
    3. Inspect repeated child elements, which become JSON arrays.
    4. Download the JSON only after confirming the mapping matches the receiving application.

    Quick example

    Example input

    <user id="7"><name>Ada</name><role>Engineer</role></user>

    Expected output

    {
      "user": {
        "@attributes": { "id": "7" },
        "name": "Ada",
        "role": "Engineer"
      }
    }

    There is no universal lossless XML-to-JSON mapping. Namespaces, mixed content, comments, processing instructions, and element order need separate review.

    Best use cases

    • Inspect simple XML API responses as JSON.
    • Prepare straightforward XML records for JavaScript processing.
    • Review attributes and repeated elements before data import.

    Reference standards and behavior

    W3C XML and RFC 8259 define different data models. This page uses a documented convenience mapping and does not claim a canonical or lossless conversion.

    Sources checked July 24, 2026. Standards can change; review the source pages before formal integration.

    Notes

    • The parser rejects malformed XML.
    • Attributes use @attributes, repeated child names become arrays, and mixed text can use #text.
    • Comments, processing instructions, document type details, and exact ordering are not preserved.

    FAQ

    How are XML attributes represented?

    Attributes are placed in an @attributes object on the converted element.

    What happens to repeated elements?

    Repeated child names become a JSON array in document order.

    How is element text represented?

    Text-only elements become strings; direct text beside child elements is stored in #text.

    Is the conversion lossless?

    No. Comments, processing instructions, document type details, namespaces, and exact mixed-content order are not fully preserved.

    What happens with malformed XML?

    The browser parser reports an error and the page does not produce JSON.