DevTools Logo

XML to JSON Converter

XML to JSON Converter

Convert XML documents to JSON with attribute handling and configurable parsing options

Input & Settings

2 spaces

About this tool

This tool converts XML documents into JSON objects using a robust client-side parser. It preserves element nesting, handles attributes (prefixed by default with @_), parses numbers and booleans, and trims whitespace. Use it to bridge XML-based APIs, config files, or legacy data into modern JSON workflows — all processing happens locally in your browser, nothing is uploaded.

Examples & Use Cases

Simple XML to JSON

<!-- XML Input -->
<person>
  <name>John Doe</name>
  <age>30</age>
  <active>true</active>
</person>

// JSON Output
{
  "person": {
    "name": "John Doe",
    "age": 30,
    "active": true
  }
}

A basic XML element with text content is converted to a nested JSON object. Numeric and boolean values are parsed automatically.

XML with Attributes

<!-- XML Input -->
<book id="123" category="fiction">
  <title lang="en">The Great Gatsby</title>
  <year>1925</year>
</book>

// JSON Output
{
  "book": {
    "@_id": 123,
    "@_category": "fiction",
    "title": {
      "@_lang": "en",
      "#text": "The Great Gatsby"
    },
    "year": 1925
  }
}

Attributes are prefixed with @_ by default so they never collide with child element names. Text alongside attributes is nested under #text.

Repeated Elements Become Arrays

<!-- XML Input -->
<library>
  <book><title>Book 1</title></book>
  <book><title>Book 2</title></book>
</library>

// JSON Output
{
  "library": {
    "book": [
      { "title": "Book 1" },
      { "title": "Book 2" }
    ]
  }
}

Sibling elements with the same tag name are automatically grouped into a JSON array — the natural representation for repeated XML elements.

    About this tool

    Convert XML to JSON online instantly. Free converter with attribute handling and formatting options — no signup, runs entirely in your browser. XML to JSON Converter runs in the browser on DevTools. There is no signup, and your input stays on this device unless the tool explicitly performs a live network lookup.

    What this tool does not do

    • XML to JSON Converter is a free in-browser utility, not a hosted API. It does not keep server-side history and is not a substitute for production verification in your own stack.

    How do I use this tool?

    1. How do I use XML to JSON Converter?

      Open XML to JSON Converter, enter or paste your input, and copy the result. The page works without an account.