XML to JSON

Turn XML from feeds, SOAP responses or config files into JSON you can use in JavaScript and modern APIs. Attributes, element text and repeated elements are mapped in a predictable way you can adjust, and the tool tells you when something such as mixed text and comments cannot be represented exactly.

Data Formats Runs in your browser

Convert XML to JSON

Empty = no prefix.
Gives a predictable shape even when an element appears once.

How to Use the XML to JSON

  1. Paste the XML.
  2. Adjust the attribute prefix, text key and options if needed.
  3. Press Convert.
  4. Copy or download the JSON and read any notes.

About This Tool

Developers consuming XML APIs from JavaScript, integration engineers migrating data, and analysts who prefer JSON tools.

Input: XML  ·  Output: JSON (.json).

Features and Limitations

Features

  • Validates XML first and points to errors by line and column.
  • Repeated elements become arrays automatically, or always, if you prefer.
  • Optional conversion of numbers and booleans.
  • Notes for mixed content and dropped comments.

Limitations

  • Comments and processing instructions are dropped.
  • In mixed content the text pieces are joined, so their order relative to child elements is lost.
  • Namespace declarations are dropped and element names keep their prefixes (ns:item).
  • Results are computed in your browser; nothing you enter is sent to a server.

Example

<book id="b1"><title>XML</title></book> becomes {"book":{"@id":"b1","title":"XML"}}.

Frequently Asked Questions

How are attributes represented?

As keys starting with the attribute prefix (default @), next to the child elements.

Why is a list sometimes an object and sometimes an array?

By default an element becomes an array only when it repeats. Tick “Always use arrays” for a consistent shape.

Are numbers converted?

Only if you tick the option; otherwise all values stay strings, which is the safest choice for IDs and codes such as 007.

Is my XML uploaded?

No. It is converted in your browser.

Related Tools

More like this: all Data Formats tools, all Developer & Web tools or the TinySandy home page.