XML to JSON
Convert XML documents into clean, predictable JSON
What is an XML to JSON converter?
XML was the default data format of the 2000s, and it survives in RSS feeds, banking APIs, SOAP services and legacy config files. Modern JavaScript, Python and Go code reads JSON far more naturally. An XML to JSON converter translates a document into plain objects using a predictable scheme: every element becomes an object, attributes are prefixed with "@@" so "id" the attribute never collides with a child element called "id", text content lives under "@text", and repeated sibling elements collapse into arrays so you never lose a
What it can do
- Parse nested elements into JSON objects
- Separate attributes (@@ prefix) from text (@text) from children
- Group repeated sibling elements into arrays automatically
- Handle CDATA sections, comments, declarations and self-closing tags
- Report mismatched or unclosed tags with a clear error
- Format the JSON with readable indentation
When to use it
- Reading RSS/Atom feeds or SOAP-style responses
- Migrating XML config into JSON-based pipelines
- Inspecting what a legacy XML API actually returns
- Building JSON test fixtures from XML reference data
Privacy: the conversion happens entirely in your browser — nothing you paste is ever uploaded.
The mapping this converter uses
- XML attributes become keys prefixed with
@(price currency="EUR"→{"@currency":"EUR"}) so they never collide with child elements. - An element that mixes text and children keeps its text under
#text; a plain-text element maps to a bare string. - Repeated sibling elements collapse into arrays; the XML declaration, comments and processing instructions are dropped.
Attributes and text nodes need a convention
Attributes and text, never mixed
Attributes become "@@id"-style keys and text lives under "@text", so an attribute and an element with the same name can never overwrite each other.
Lists stay lists
Repeated sibling elements collapse into a JSON array automatically — a catalog of five books becomes an array of five objects, not one overwritten book.
Tolerant of real XML
CDATA, comments, DOCTYPE and self-closing tags all parse cleanly, while genuinely malformed XML fails with a descriptive message.
Frequently asked questions
How are attributes represented?⌄
Attributes become keys prefixed with "@@", e.g. <book id="5"> becomes {"@@id":"5"}. This prevents the classic collision between an attribute named "id" and a child element also named "id".
What happens to repeated elements?⌄
Repeated sibling elements with the same name are grouped into a JSON array automatically. A single occurrence stays a single object, and multiple occurrences become an array — both cases read intuitively.
Is my XML uploaded anywhere?⌄
No. Everything runs in your browser with plain JavaScript — nothing you paste is transmitted or stored.
Where did my attribute go in the JSON output?⌄
Look for the @-prefixed key on the same object as its element. If you see only #text, the element had attributes AND content; if you expected an attribute and find nothing, it lived on a parent node — expand the tree one level up.