CoreJSON

XML to JSON

This XML to JSON converter turns XML into a JSON object instantly. Tag attributes are kept as @_-prefixed fields by default, text alongside attributes uses a #text key, and attributes can be ignored if you prefer. XML is validated before parsing with errors located by line and column, and everything runs locally.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste your XML

    Paste XML text with or without an <?xml?> declaration; repeated tags, attributes and self-closing tags are all supported.

  2. 2

    Choose whether to keep attributes

    Attributes are kept as @_-prefixed fields by default; tick "Ignore XML attributes" to reconvert without them.

  3. 3

    Copy the JSON

    Choose the indentation and copy the standard JSON, or click ⇄ to send the result to the JSON to XML tool.

  4. 4

    Reuse the output

    Feed the JSON into a tool on this site or into your application code.

Key features

Attributes fully preserved

<a id="7"> becomes {"a":{"@_id":"7"}}, keeping attribute information, which can be turned off when not needed.

Repeated tags become arrays

A tag appearing more than once is merged into an array while a single occurrence stays an object, matching intuitive structure.

Strict validation first

Tag closure and other syntax are validated before conversion; <a> mismatched with </b> reports the line and column.

Entities decoded

Entity references such as &amp;, &lt;, &gt; and &quot; are restored to their original characters.

Works with SOAP and SVG

Suitable for well-formed XML including SOAP messages and SVG documents.

Local and private

Parsing happens in your browser and the data is not uploaded.

Common errors & troubleshooting

  • ! Tags must be closed correctly; the line and column in an error point to the first mismatched closing tag.
  • ! When an element has both attributes and text content, the text goes under a #text key, for example {"a":{"@_id":"7","#text":"hi"}}.
  • ! A self-closing tag <x/> and an empty tag <x></x> both yield an empty string — XML cannot express null.
  • ! HTML is not strict XML, so tidy it into XHTML style before converting.

Frequently asked questions

Where do XML tag attributes go?

By default they are kept as @_-prefixed keys (an id attribute becomes @_id) so they are distinguished from child elements. If you only care about content, tick "Ignore XML attributes" for a clean structure.

Why do some tags become arrays and others objects?

When a tag name appears twice or more under the same parent it is merged into an array; a single occurrence stays an object. This matches the convention of most XML data-binding tools.

Are SOAP, SVG and HTML supported?

It works for well-formed XML, including SOAP messages and SVG. HTML is not strict XML (it has many unclosed tags), so tidy it into XHTML style first.

Is my XML uploaded?

No. Parsing happens locally in your browser.

Related tools