tools

    XML formatter

    Format, minify and validate XML with the exact error location, and convert it to and from JSON.

    Mode
    Indent
    How XML maps to JSON
    <a>text</a>
    {"a": "text"} An element with only text is a string.
    <a/>
    {"a": ""} An empty element is an empty string.
    <a id="1"/>
    {"a": {"@id": "1"}} Attributes get an @ prefix.
    <a id="1">text</a>
    {"a": {"@id": "1", "#text": "text"}} Text beside attributes or child elements goes in #text, trimmed.
    <a><b>1</b><b>2</b></a>
    {"a": {"b": ["1", "2"]}} A repeated element becomes an array; a single one does not.
    <![CDATA[…]]>
    "…" CDATA counts as text. Comments and processing instructions are dropped.
    <root><item>1</item></root>
    [1] JSON to XML: anything but a single-key object is wrapped in <root>, and array items in arrays become <item>.