X→J

XML to JSON

Convert XML into JSON, with attributes, nesting, and repeated tags handled automatically.

xml-to-json.tool
0 chars
JSON output will appear here
Nothing you paste here is ever sent to a server - conversion happens locally in your browser.
Overview

What is a xml to json?

This tool converts XML into JSON using a common, predictable convention: element attributes become keys prefixed with @, text content alongside attributes becomes a #text key, and repeated sibling elements automatically become a JSON array. It's built as a standalone parser rather than relying on a browser's native XML parser, so behavior stays consistent.

Quick start

How to use this tool

  1. 1Paste your XML, or upload an .xml file.
  2. 2Toggle Infer types to convert numeric and boolean-looking text into real JSON types, or leave everything as strings.
  3. 3Click Convert - nested elements, attributes, and repeated tags are all handled automatically.
  4. 4Copy the JSON or download it as a .json file.
Where it helps

Common use cases

Converting a legacy XML API response into JSON for a modern frontend
Reading an XML config or feed file as structured JSON
Migrating data from an XML-based system into a JSON-based one
Quickly inspecting what's actually inside a large or unfamiliar XML document
Good to know

Frequently asked questions

How are XML attributes represented in the JSON?

Each attribute becomes a key prefixed with @ - for example <price currency="USD">29.99</price> becomes { "@currency": "USD", "#text": 29.99 }.

What happens with repeated elements, like multiple <item> tags?

They're automatically collected into a JSON array under that tag name, rather than overwriting each other.

Does it support CDATA sections and XML entities?

Yes - CDATA content is extracted as-is, and standard entities (&amp;, &lt;, &gt;, &quot;, &apos;, and numeric entities) are decoded correctly.

Is my XML uploaded anywhere?

No - parsing happens entirely in your browser using a built-in parser, whether you paste the XML or upload a file.

quick_facts.json

{

"runs_in_browser": true,

"data_sent_to_server": false,

"signup_required": false,

"price": "free",

"category": "Encoding"

}

Related tools

B64
No signup
Base64 Encoder

Encode text to Base64, with correct Unicode handling.

Open tool
B64
No signup
Base64 Decoder

Decode Base64 back to readable text, with correct Unicode handling.

Open tool
URL
No signup
URL Encoder

Percent-encode URLs and query strings, component or full-URI mode.

Open tool