XML to JSON Converter
Convert an XML document into JSON using a predictable, documented mapping: attributes become @name keys, repeated sibling elements become arrays, and mixed text becomes #text. The conversion runs in your browser.
How it works
The mapping this tool uses
XML and JSON do not have the same data model, so any conversion has to pick conventions. There is no single standard, which is why two converters can give different output for the same input. This tool uses the most widely recognised set:
- Attributes become keys prefixed with
@:<book id="1">→"@id": "1". - Repeated sibling elements with the same name become a JSON array.
- An element with only text becomes a plain string.
- Mixed content — text alongside child elements — puts the text under
#text. - The root element is preserved as the single top-level key.
Why the output is all strings
XML has no native types: <year>2026</year> is the string "2026", not the number 2026. Type information in XML lives in a schema, not in the document. This tool does not guess types, because guessing is how leading zeros get eaten and version numbers like 1.10 turn into 1.1.
If you need numbers, coerce them after conversion where you know the schema.
The single-child ambiguity
This is the trap in every XML-to-JSON conversion. A list with one element looks identical to a single value: <items><item>a</item></items> produces an object, while the same document with two items produces an array. Code that reads the output must handle both, or you will get a bug the first time a list has exactly one entry.
What people use it for
- Moving a legacy XML API's response into a JavaScript or Python codebase that expects JSON.
- Inspecting a SOAP response in a shape that is easier to read and query.
- Converting a config file as the first step of a migration.
- Feeding XML data to a tool that only accepts JSON, such as a JSON-path query or a schema validator.
- Reading an RSS feed programmatically without an XML library.
Nothing is uploaded. This tool runs entirely in JavaScript in your browser. Your input is never sent to a server, never logged and never stored, and no account is required. Once the page has loaded you can go offline and it still works — open your browser's network tab and watch if you'd like to confirm it.
Frequently asked questions
Why are all my numbers strings?
XML has no types — every value in an XML document is text, and type information lives in a schema rather than the document. This tool does not guess types, because guessing corrupts leading zeros and version strings like 1.10. Convert the fields you know about after the fact.
Why is a one-item list an object rather than an array?
Because XML cannot distinguish them. A parent with one child element looks exactly like a parent with a single value. Any consumer of converted XML has to handle both shapes, which is the most common source of bugs when moving from XML to JSON.
Is there a standard for XML to JSON conversion?
No single standard. The @attribute and #text convention used here is the most widely recognised, and is close to what libraries such as xmltodict produce, but other converters make different choices.
Does it handle namespaces?
Namespace prefixes are kept as part of the element name, so soap:Body becomes the key soap:Body. Namespace declarations appear as @xmlns attributes. The tool does not resolve or strip prefixes.
Is my XML sent to a server?
No. The conversion uses your browser's own XML parser and runs entirely locally.
Tools that run where your code is
This page does its work in your browser because sending your data to a server to process it is a bad default. Catalase applies the same idea to AI coding: a free, open-source code editor that runs language models on your own machine through Ollama, with no account and no telemetry. Cloud models are there when you choose one, not by default.
Related tools
- XML formatter — Indent and check XML well-formedness.
- JSON to CSV — Flatten JSON into spreadsheet rows.
- YAML to JSON — Convert between YAML and JSON.