Type a tool name, for example "keyword density" or "transcript".
Convert XML data to JSON format. Paste text, upload a file, or drag & drop.
Drag & drop an XML file here
or click to browse
An XML to JSON converter turns XML markup into JSON objects and arrays so web apps, APIs and scripts can read the data. With this free tool you paste XML or upload a file, choose a JSON layout, and get formatted output plus key count, depth and size stats, ready to copy or download.
XML to JSON conversion rewrites data stored in XML tags as JSON keys and values. XML wraps each piece of data in opening and closing tags, and it can add attributes and namespaces. JSON uses curly braces for objects, square brackets for arrays and simple key-value pairs. Both formats describe nested data, so a child element in XML becomes a nested object in JSON.
JSON has no attributes, so every converter follows a convention. This tool uses these rules:
_category.__text.dc:title are removed by default, leaving title.Neither format is better in every case. JSON is shorter and maps directly to objects in JavaScript, Python and most other languages, which is why REST APIs favor it. XML supports attributes, comments, schemas and mixed text and tags, so it remains common in RSS and Atom feeds, sitemaps, SVG files, SOAP services and many configuration files. You convert from XML to JSON when the system that receives the data expects JSON.
You can convert a document in six steps, and the whole process takes a few seconds.
dc:title exactly as written.Not sure what to paste? Click Sample to load a small bookstore document, and Reset to start over.
| Option | Best for | Trade-off |
|---|---|---|
| Pretty Print (2 spaces) | Reading and sharing | Larger text |
| Pretty Print (tabs) | Projects that indent with tabs | Larger text |
| Minified | API payloads and storage | Hard to read |
Here is a short document with two books, one of which carries attributes on its title: <bookstore><book category="fiction"><title lang="en">The Great Gatsby</title><year>1925</year></book><book category="science"><title lang="en">A Brief History of Time</title><year>1988</year></book></bookstore>
With the default settings, the first book converts to this shape: {"_category":"fiction","title":{"_lang":"en","__text":"The Great Gatsby"},"year":"1925"}. The two book elements share a name, so they sit together in one array under a book key, all inside a bookstore object.
Now tick Remove top-level root element and convert again. The output starts with the book array directly, one level shallower, so Max Depth drops by one. That is handy when your code already knows it is reading a bookstore and does not need the wrapper.
The results panel gives you three numbers, a collapsible tree and the final JSON, and each one tells you something you can act on.
Anyone who receives data in XML but needs it in JSON benefits, and the most common situations are practical ones.
Most failed conversions come from malformed XML, so a few habits prevent nearly all of them.
&, and a less-than sign inside text as <.a:id and b:id would then share one name. Clear the Strip namespace prefixes box when the prefixes carry meaning.This converter changes the format in one direction only, from XML to JSON, and it cannot turn JSON back into XML. Because JSON has no attributes, the underscore and __text naming is a convention. Other converters can name those keys differently, so do not assume that output from two converters will match.
Mixed content, where text sits between child tags, may not keep its exact order. Numbers and dates stay as text, and very large documents can take longer to convert, so split a huge file into smaller parts if the page slows down. Always review the Structure Preview before relying on the result in production.
Paste your markup into the XML Data box above, press Convert to JSON, and you will have clean, correctly nested JSON to copy or download in seconds. For more utilities of this kind, browse the web developer tools collection.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market