XML to JSON Converter
Paste an XML document and get a JSON representation in your browser. Attributes become @-prefixed keys, element text is wrapped in a #text key, and repeated sibling tags collapse into arrays.
How to use this tool
- 1
Paste or type your XML into the input box.
- 2
Read the converted JSON in the output panel below, which updates as you type.
- 3
If the XML is malformed, fix the error shown in red and the output will reappear.
- 4
Select the JSON from the output panel to copy it into your project.
How does this XML to JSON converter map elements, attributes, and text?
XML and JSON describe data differently, so any conversion has to pick conventions. This tool parses your input with the browser's built-in DOMParser in text/xml mode, then walks the resulting DOM tree with a recursive function. The document's root element name becomes the single top-level key. Each child element becomes a nested key under its parent, attributes are stored as keys prefixed with @ (so id='5' becomes '@id': '5'), and an element's text content is placed under a '#text' key rather than becoming the value directly — even a simple leaf like <name>John</name> produces {'name': {'#text': 'John'}}. When a parent has several child elements with the same tag name, those siblings are merged into a JSON array so none are lost. An element with no attributes and no text becomes null. The mapping is deliberately lossy: namespaces survive only as literal prefixed key names (ns:tag) and are never resolved, comments, processing instructions, and CDATA sections are dropped to null, the original order of mixed text-and-element content is not preserved, and nothing is type-coerced, so numbers and booleans stay as strings like '42' and 'true'.
Common use cases
Inspect a SOAP or legacy XML API response as JSON before wiring it into a JavaScript front end.
Convert an RSS or Atom feed snippet into JSON to prototype a parser quickly.
Turn a config file or build manifest written in XML into JSON to eyeball its structure.
Pull values out of an XML sitemap or data export when a JSON shape is easier to traverse.
Teach or learn how attributes, repeated tags, and text nodes map between the two formats.
Sanity-check that a small XML payload is well-formed, since malformed input shows a parser error.
Frequently asked questions
Is my XML uploaded to a server?▼
Why is text wrapped in a #text key instead of being the value?▼
What does the @ prefix mean?▼
How are repeated tags handled?▼
Are numbers and booleans converted to real JSON types?▼
What happens to CDATA, comments, and namespaces?▼
Why do I see a red error message?▼
Related tools
JWT Decoder
Decode JSON Web Tokens (JWT) instantly — inspect the header, payload, and signature claims. Runs entirely in your browser; tokens never leave your device. Safe for production secrets.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Catches syntax errors with line numbers, pretty-prints with adjustable indent, supports large payloads. Runs in your browser — no upload.
XML Formatter & Beautifier
Format and beautify XML documents — proper indentation, line breaks, namespace handling. Useful for SOAP responses, sitemaps, RSS feeds, and Android resource files.
Base64 Encoder & Decoder
Encode and decode Base64 strings.
URL Encoder & Decoder
Encode/decode URL-safe strings.
HTML Entity Encoder & Decoder
Convert special characters to/from HTML entities.