XML to JSON
Convert XML documents into structured JSON instantly in your browser. Attributes become @-prefixed keys and repeated elements become arrays.
Predictable Structure
Attributes, text, and repeated elements map to JSON consistently — documented, not guessed.
Clear Error Messages
Flags malformed or mismatched XML tags with a specific parser error.
Local Processing
Your data never leaves your browser. Privacy first conversion.
How to Convert XML to JSON
- Paste your XML document — an API response, a config file, an RSS/SOAP fragment.
- Click Convert.
- Structured JSON appears in the output pane: attributes become @-prefixed keys, repeated elements become arrays.
- Malformed XML (mismatched or unclosed tags) is reported with a specific parser error instead of partial output.
Example: Attributes and Repeated Elements
Input — XML
<catalog> <book id="bk-101" lang="en"><title>Clean Data</title></book> <book id="bk-102"><title>Fast Pipelines</title></book> </catalog>
Output — JSON
{
"catalog": {
"book": [
{
"@id": "bk-101",
"@lang": "en",
"title": "Clean Data"
},
{
"@id": "bk-102",
"title": "Fast Pipelines"
}
]
}
}The two <book> elements collapse into one "book" array, and each attribute surfaces as an @-prefixed key — distinguishable at a glance from child elements like title.
A predictable, documented mapping
XML-to-JSON has no single universal convention, so this tool commits to one and applies it consistently: attributes get an @ prefix, element text becomes the value, and elements repeated under the same parent become an array. It mirrors the JSON-to-XML page exactly, so converting in one direction and back preserves your structure.
One thing to watch: single vs. repeated elements
An element appearing once maps to an object, while the same element appearing twice maps to an array — that’s inherent to the XML data model, which JSON has to guess from occurrence counts. If your downstream code expects an array, make sure it tolerates the single-occurrence object case too.
Frequently Asked Questions
Because XML has no native type system — every value between tags is just text, and there is no reliable way to guess whether "007" should become the number 7, the string "007", or stay as-is. Rather than guess and sometimes guess wrong, every XML text value is converted to a JSON string consistently. If you need real numbers and booleans, you will need to convert those specific fields after the fact.
They are dropped — JSON has no equivalent place to put them, so <!-- comments --> and <?processing instructions?> are silently ignored during conversion; only actual elements, attributes, and text survive.
Elements that share the same tag name and the same parent are collected into a JSON array in document order — <items><item>a</item><item>b</item></items> becomes {"items": {"item": ["a", "b"]}}. A tag that appears only once under its parent stays a single value rather than a one-item array.
No. Parsing uses the browser's native XML parser and the conversion runs entirely client-side — nothing you paste here is ever transmitted anywhere.
You'll get a clear parse error rather than a best-effort guess at the structure — the browser's XML parser refuses to guess how to recover from malformed markup, so a mismatched closing tag or an unclosed element is reported as an error instead of silently producing incorrect JSON.
Related Tools
JSON to XML
Convert JSON into well-formed XML markup.
JSON Formatter
Make messy, minified JSON readable with customizable indentation.
JSON Validator
Check JSON validity with precise line/column errors.
Base64 Decoder
Decode Base64 text back to readable Unicode instantly.
URL Encoder
Safely percent-encode text for use in URLs and query strings.
JSON to YAML
Convert JSON documents to clean, indented YAML.