Skip to content

XML to JSON

Convert XML to JSON format.

Loading…

About XML to JSON

Feeds, exports and older integrations still arrive as XML while your code wants JSON. The converter first checks that the document is well-formed, then maps it: attributes become keys that start with @_, sibling elements with the same name become an array, and text beside attributes goes under a #text key. Values stay as strings unless you tick the box that converts numbers and true or false, which keeps values such as 007 as text.

Features

  • Attributes become keys with an @_ prefix
  • Sibling elements with the same name become an array
  • Text that sits beside attributes goes under a #text key
  • Optional number and true/false conversion; zero-padded values, hex and exponents stay text
  • Malformed XML is reported with a line and column
  • CDATA sections and numeric character references are decoded

Limitations

  • The document needs exactly one root element; two top-level elements are rejected.
  • A single child element is not wrapped in an array, so a list that happens to hold one item looks like a plain value.
  • Comments and the XML declaration are dropped, and custom entity declarations (<!ENTITY>) are refused.
  • Text mixed in between child tags is joined under #text, so spacing and position around the tags are lost.

How it works

  1. Paste XML with a single root element into the XML Input panel.
  2. Tick Convert numbers and true/false if you want typed values; leave it clear to keep everything as text.
  3. Select Convert to JSON. Ticking or clearing the box runs it again.
  4. Read the indented result in the JSON Output panel, or the error message in the middle column.
  5. Copy it with Copy Output.

Example input

<book id="1">
  <title>Auro Guide</title>
  <tag>json</tag>
  <tag>xml</tag>
</book>

Frequently asked questions