Free Tools Grid

XML to JSON Converter

Developer Tools

Convert XML documents into clean, indented JSON. Attributes are preserved by default with a `@_` prefix.

Runs entirely in your browser
Loading tool...

About XML to JSON Converter

The XML to JSON Converter parses any well-formed XML and emits an equivalent JSON document. It's the tool to reach for when you need to feed XML data (RSS, SOAP, sitemap, config) into a JSON-first system like a JavaScript app, a NoSQL database, or a serverless function.

XML carries information that JSON doesn't natively support — attributes and mixed content — so the converter uses two conventions to keep round-tripping faithful. Attributes are placed alongside child elements with a `@_` prefix so they don't collide with element names. Text content sits in a sibling property when an element has both attributes and a value. You can toggle attribute preservation off if you only care about element structure. Everything runs in your browser via `fast-xml-parser`.

How to use

  1. 1

    Paste your XML

    Drop the XML document or fragment into the input editor.

  2. 2

    Decide on attribute handling

    Toggle Preserve attributes on (default) to keep `@_attrName` keys alongside element keys. Turn it off for a structure-only JSON tree.

  3. 3

    Copy or download the JSON

    Use the Copy or Download (.json) button.

Examples

Element with attributes

Attributes appear with a `@_` prefix so they don't collide with element names.

Input

<book id="1">
  <title>Hyperion</title>
  <author country="USA">Dan Simmons</author>
</book>

Output

{
  "book": {
    "@_id": 1,
    "title": "Hyperion",
    "author": {
      "@_country": "USA",
      "#text": "Dan Simmons"
    }
  }
}

Frequently asked questions

Why are attributes prefixed with `@_`?+

It's a convention from `fast-xml-parser` that prevents an attribute named `id` from clashing with a child element also named `id`. You can post-process the JSON to rename if needed.

What happens to mixed content (text + elements)?+

Text content alongside child elements is captured in a `#text` property. Pure text elements become string values directly.

Are numeric and boolean values typed?+

By default the parser tries to coerce numeric attribute and text values to `number`. Pure strings stay as strings.

Does it handle namespaces?+

Namespaced element names appear in the JSON exactly as they did in the XML (e.g. `soap:Envelope`). You can post-process to strip prefixes if not needed.

Is my XML sent anywhere?+

No. Parsing happens entirely in your browser.