XML to JSON Converter

Convert XML into readable JSON, including attributes and repeated elements.

XML input
JSON output

About this tool

Convert XML to JSON in your browser. Attributes become @name keys, text mixed with elements becomes #text, and repeated elements become arrays — three rules stated up front, so the output is never a surprise.

The XML is validated before parsing: a mismatched closing tag or an unclosed element is reported with its line and column, in the same plain-English voice as the rest of the site.

CDATA sections keep their raw content, comments are dropped, and the whole document never leaves the tab.

How to use it

  1. Paste your XML, or drop an .xml file onto the input pane.
  2. The JSON appears on the right as you type. Repeated elements read as arrays; attributes read with an @ prefix.
  3. Copy or download. Malformed input gets the exact line and column of the break, not a stack trace.

Worked example

The sample reads version as @version, the server element with its two attributes, and the two admin elements as one array — the three rules of the mapping, one document.

Elements, attributes, repeats

Frequently asked questions

How do attributes come out?
As @-prefixed keys: <b c="d">x</b> becomes {"@c": "d", "#text": "x"}. The prefix keeps attributes and elements from colliding, and matches the convention the JSON to XML direction writes.
What about repeated elements?
Two <a> children under one parent become one JSON array: {"a": ["text", "more"]}. A single child stays a plain value — the shape follows the document.
Does it handle CDATA and comments?
CDATA content is kept exactly — <![CDATA[keep <this>]]> reads as the string keep <this>. Comments are dropped, which is what JSON conversion convention does with them.
My XML uses namespaces. What happens?
Namespaced element and attribute names come through as written, prefix and all. The prefixes are part of the name in the JSON; resolvable URIs belong to the XML layer, not the JSON one.
Is my data uploaded anywhere?
No. The parse and conversion run locally; a dropped file is read in the tab and never leaves it.