XML to JSON Converter

Paste any XML document and instantly convert it to clean, readable JSON. Supports attributes, nested elements, repeated nodes, and mixed content — entirely in your browser.

XML Input
JSON Output
Instant Conversion
Converts any XML document to JSON in milliseconds using the browser's built-in XML parser
🔒
100% Private
Everything runs client-side in your browser — your XML data is never sent to any server
🧩
Attributes & Arrays
Correctly handles XML attributes, repeated sibling nodes (converted to JSON arrays), and nested structures
🎛️
Flexible Output
Choose between 2-space, 4-space indented output or fully minified JSON — copy or download directly

Conversion Examples

1 — Simple element with attributes

XML Input
<user id="42" active="true"> <name>Alice</name> <email>alice@example.com</email> <role>admin</role> </user>
JSON Output
{ "user": { "@id": "42", "@active": "true", "name": "Alice", "email": "alice@example.com", "role": "admin" } }

2 — Repeated sibling nodes become a JSON array

XML Input
<catalog> <item>Apple</item> <item>Banana</item> <item>Cherry</item> </catalog>
JSON Output
{ "catalog": { "item": [ "Apple", "Banana", "Cherry" ] } }

3 — Nested structure (API response)

XML Input
<response status="200"> <data> <product id="7"> <title>Wireless Mouse</title> <price currency="USD">29.99</price> </product> </data> </response>
JSON Output
{ "response": { "@status": "200", "data": { "product": { "@id": "7", "title": "Wireless Mouse", "price": { "@currency": "USD", "#text": "29.99" } } } } }

Convert XML to JSON Format — Fast, Free, and Accurate

XML and JSON are the two most widely used data interchange formats on the web, but they serve increasingly different audiences. XML was the default for APIs, configuration files, and data feeds through the 2000s, and countless enterprise systems still produce XML output today. JSON took over as the default for modern REST APIs, JavaScript applications, and NoSQL databases because of its lighter syntax and direct mapping to programming language objects. When you need to move data from an older XML source into a modern application, converting XML to JSON is the most practical first step.

This XML to JSON converter handles the most common patterns you'll encounter in real-world XML: simple key-value elements, attributes (prefixed with @ in the output), deeply nested structures, and repeated sibling nodes that automatically become JSON arrays. The conversion runs entirely in your browser using the native DOMParser API, so there is no upload, no server round-trip, and no risk of your data being logged or stored by a third party.

Common use cases include converting RSS or Atom feed XML into JSON for a JavaScript front-end, migrating SOAP API responses to a REST-friendly format, transforming configuration files from XML-based systems like Maven or Spring into JSON for modern tooling, and cleaning up XML exports from databases or CMS platforms before importing them into a new system. The tool supports XML documents of any size that your browser can hold in memory, making it practical for both small snippets and large data exports.

How to Convert XML to JSON

  1. Paste your XML: Copy the XML content from your source — an API response, a file, a database export — and paste it into the left panel. The tool accepts any well-formed XML document including those with a declaration (<?xml version="1.0"?>).
  2. Choose your output format: Select 4-space indent for readable output, 2-space for compact-but-readable JSON, or Minified to produce a single-line string suitable for APIs and storage.
  3. Set attribute handling: By default, XML attributes are included in the JSON output prefixed with @. Uncheck "Include attributes" to drop them from the output if your use case does not require them.
  4. Click Convert: The JSON output appears instantly in the right panel. Any XML parsing errors are shown directly in the output area with a description of the problem.
  5. Copy or download: Use the Copy JSON button to send the output to your clipboard, or Download .json to save it as a file. Both options work without any page reload.

XML to JSON Conversion Rules Explained

Understanding how XML concepts map to JSON makes it easier to work with the output:

  • Element names become JSON keys. The root element becomes the top-level key in the resulting JSON object. Child elements become nested keys under their parent.
  • Text content becomes the value. If an element contains only text and no attributes or child elements, it is converted to a plain string value. For example, <city>Paris</city> becomes "city": "Paris".
  • Attributes are prefixed with @. An attribute like id="5" on an element becomes "@id": "5" alongside the element's other children in the JSON object.
  • Repeated elements become arrays. When two or more sibling elements share the same tag name, they are collected into a JSON array. This is the most important structural difference between XML and JSON since XML allows repeated keys while JSON objects do not.
  • Mixed content uses #text. When an element has both attributes and a text value, the text is stored under the key #text alongside the attribute keys. Enable "Force text nodes as #text" to apply this rule to all text content regardless of context.