XML to JSON

Convert XML documents into structured JSON instantly in your browser. Attributes become @-prefixed keys and repeated elements become arrays.

Input
OutputREADY

Predictable Structure

Attributes, text, and repeated elements map to JSON consistently — documented, not guessed.

Clear Error Messages

Flags malformed or mismatched XML tags with a specific parser error.

Local Processing

Your data never leaves your browser. Privacy first conversion.

How to Convert XML to JSON

  1. Paste your XML document — an API response, a config file, an RSS/SOAP fragment.
  2. Click Convert.
  3. Structured JSON appears in the output pane: attributes become @-prefixed keys, repeated elements become arrays.
  4. Malformed XML (mismatched or unclosed tags) is reported with a specific parser error instead of partial output.

Example: Attributes and Repeated Elements

Input — XML

<catalog>
  <book id="bk-101" lang="en"><title>Clean Data</title></book>
  <book id="bk-102"><title>Fast Pipelines</title></book>
</catalog>

Output — JSON

{
  "catalog": {
    "book": [
      {
        "@id": "bk-101",
        "@lang": "en",
        "title": "Clean Data"
      },
      {
        "@id": "bk-102",
        "title": "Fast Pipelines"
      }
    ]
  }
}

The two <book> elements collapse into one "book" array, and each attribute surfaces as an @-prefixed key — distinguishable at a glance from child elements like title.

A predictable, documented mapping

XML-to-JSON has no single universal convention, so this tool commits to one and applies it consistently: attributes get an @ prefix, element text becomes the value, and elements repeated under the same parent become an array. It mirrors the JSON-to-XML page exactly, so converting in one direction and back preserves your structure.

One thing to watch: single vs. repeated elements

An element appearing once maps to an object, while the same element appearing twice maps to an array — that’s inherent to the XML data model, which JSON has to guess from occurrence counts. If your downstream code expects an array, make sure it tolerates the single-occurrence object case too.

Frequently Asked Questions

Related Tools