XML to JSON Converter
Convert XML to JSON online. Maps attributes to @keys, repeated elements to arrays, and text to #text, keeping values as strings. Runs entirely in your browser.
How it was mapped
Import from File
Drag & drop a file here
or
Supports .txt, .csv, .log, .json and other text files
All conversion happens locally in your browser. No data is sent to any server. Your XML stays completely private.
What It Does
This tool reads XML — the format behind SOAP APIs, RSS and Atom feeds, sitemaps, office documents, and countless enterprise systems — and converts it to clean, pretty-printed JSON your code and modern APIs can consume directly. The tricky part of XML-to-JSON is that XML carries information JSON has no direct slot for: attributes, mixed text-and-elements, repeated tags, and namespaces. This converter uses a clear, consistent convention so nothing is lost: attributes become @-prefixed keys, an element's text (when it also has attributes or children) becomes a #text key, and repeated elements with the same name collapse into an array. Because XML has no types, every value is kept as a string rather than guessed at, which protects codes like 007 or versions like 1.0. When it meets something JSON can't fully represent — namespaces, CDATA, mixed content, or processing instructions — it converts what it can and tells you, instead of failing or dropping data silently.
When to Use It
- You have an XML API response, SOAP payload, or RSS/Atom feed and need it as JSON for a JavaScript app or modern API.
- You're debugging a malformed XML file and want a parser that points to the line where it breaks.
- You need to see how attributes, repeated elements, and namespaces map into JSON before writing the conversion in code.
- You're migrating data out of a legacy XML-based system into a JSON-based one and want a faithful, ready-to-paste result.
Worked Examples
<note><to>Ada</to><from>Alan</from><body>Hello</body></note>
A simple element-only document. Each child becomes a key with a string value: { note: { to: "Ada", from: "Alan", body: "Hello" } }.
<book id="bk101" lang="en">Dune</book>
Attributes plus text. id and lang become @id and @lang, and the element's text becomes #text: { book: { "@id": "bk101", "@lang": "en", "#text": "Dune" } }.
<library><book>Dune</book><book>Foundation</book></library>
Two <book> elements share a tag name, so they collapse into an array: { library: { book: ["Dune", "Foundation"] } } — not just the last one.
Features
How to Use
1. Paste or upload XML in the input area. 2. The JSON appears instantly, pretty-printed. 3. Check the insights panel to see how attributes and repeated elements were mapped and whether anything (namespaces, CDATA, mixed content) needs a second look. 4. Click Copy or Download to save the result.
Common Mistakes
- Expecting numbers and booleans. Every value comes out as a string because XML has no types — coerce the fields you need after converting.
- Assuming a single repeated element becomes an array. One <item> is a plain value; only two or more with the same tag name collapse into an array. Design your consuming code to handle both.
- Overlooking attributes. If you ignore the @-prefixed keys you'll miss data that lived in attributes rather than element text.
- Feeding in an HTML fragment. This is an XML parser — unclosed tags (like a bare <br>) or mismatched tags will report an error rather than being auto-corrected the way a browser would.