Skip to content
uencoder
TASK

Convert XML to JSON and back

Translate between XML and JSON for interoperability with legacy APIs, preserving attributes, namespaces, and mixed content.

  1. 1

    XML and JSON have different models: XML has attributes, namespaces, and mixed content; JSON has only objects, arrays, and scalars. Conversion requires conventions for representing attributes (e.g. @attr) and text content (e.g. #text).

  2. 2
    JSON XML Converter →

    Paste XML to get JSON, or JSON to get XML. The tool uses a consistent convention for attributes and text nodes, and handles namespaces by prefixing.

  3. 3

    Use the chain to convert JSON→XML with pretty-printing and proper declaration, for sending to XML-expecting APIs.

  4. 4
    XML Formatter →

    Format or minify XML independently — useful when the XML is valid but hard to read, or needs compression for transport.

Frequently asked questions

Why do attributes look different in the JSON?
XML attributes have no direct JSON equivalent. Converters typically prefix them (e.g. @id for attribute id) or nest them under a special key. The convention varies by tool — check the output structure before consuming it.
Can all XML be converted to JSON?
Most XML can, but mixed content (text interspersed with child elements, like <p>Hello <b>world</b></p>) is awkward in JSON and requires array conventions. Namespaces and processing instructions may also be lost or represented differently.

Workflows that solve this

Learn more

Want to understand why?

Related tools