XML to JSON Converter
Upload an XML file made of repeated records, such as a product feed or a book list, and get back JSON that holds those records as an array of objects. Every value comes out as a string, and XML that relies on namespaces or CDATA does not convert correctly, so check the result before you build on it.
Download Started!
How would you rate your experience with MiConvert?
Turning an XML record list into JSON
XML still turns up in catalog exports, older web services, RSS-style feeds and configuration files, while most front-end code and modern APIs expect JSON. A JSON copy of an XML export is easier to prototype with, paste into a test fixture or load into a tool that only reads JSON.
MiConvert reads your upload on our server with a lightweight pattern-based reader, not a full XML parser. It notes the name of the root element, treats the first child element name it finds as the record type, and collects every element with that name. Each record becomes one object that contains the record element's attributes plus the text of every leaf element inside it. The records are placed in an array under a single key named after the root tag. The file is read as UTF-8, and there are no settings to adjust.
For a flat list (one root, a repeated record element, simple fields inside), field names, field text and the attributes on each record come through as written. Several kinds of structure are lost. Nested elements are flattened, so author containing first ends up as just "first" and the parent name disappears. If a record has two fields with the same name, only one value survives. Elements of a different type next to the records, such as a magazine among book entries, are dropped. Entities such as & stay encoded, CDATA sections vanish, and every number or date becomes a quoted string.
This makes the converter a good fit for quick jobs: turning a sample export into JSON to see its shape, feeding a small data file to a JavaScript prototype, or checking what fields a supplier's XML actually carries. For SOAP responses, namespaced feeds or deeply nested documents, use a parsing library instead; the FAQ below lists common ones.
How to convert XML to JSON
- Open the XML in a text editor and confirm it is a record list: one root element, a repeated child element with the same name, and simple fields inside each record.
- Look for prefixed tag names such as soap:Envelope or g:price and for CDATA blocks; CDATA fields are dropped and namespaced XML is not handled reliably, so remove or simplify them first if you can.
- Make sure the file is saved as UTF-8. If your editor shows another encoding such as Windows-1252, re-save it as UTF-8 so accented characters are not replaced.
- Upload the .xml file and start the conversion; it is processed on our server.
- Download the .json file and compare the number of objects with the number of records you expected, then search it for leftover & entities or missing fields.
What this XML to JSON converter does
- Wraps all records in an array under one key named after your root element, for example "catalog" or "library".
- Copies the attributes of each record element, such as id="42", into that record's object as ordinary keys.
- Collects leaf fields from anywhere inside a record, so data a level or two down still appears, without its parent element name.
- Leaves every value as text, so codes such as 0012 are not turned into numbers.
- Accepts .xml uploads up to 50 MB without an account, with higher per-file limits on signed-in plans.
Video Tutorial
Watch this step-by-step tutorial to learn how to convert XML files to JSON format online for free using MiConvert.com. No software installation required.
XML to JSON questions
What does the JSON output look like? Can you show an example?
A file whose root element is library, holding book elements that each carry id="7" plus title and year fields (Dune, 1965), becomes {"library": [{"id": "7", "title": "Dune", "year": "1965"}, …]}. The root tag becomes the single top-level key, each book becomes one object, and the year stays a string. There are no options for indentation, attribute prefixes or a custom root name. If you want different formatting, run the result through any JSON formatter.
Are XML attributes kept?
Attributes on the repeated record element are kept and appear as normal keys next to the field values. Do not rely on attributes at other levels of the document being carried over. If your data keeps important values in attributes on nested elements, test with a small sample first or use a parsing library.
Why is my whole XML file inside one JSON string?
This happens when the root element carries a namespace prefix, as in soap:Envelope or ns:root. The reader does not recognize that structure, so it returns the original XML as a single string. Prefixed tags deeper in the file, such as g:price, are not handled reliably either. If the data underneath is a flat record list, you can try removing the prefixes with find-and-replace before uploading, then check the result. Otherwise use one of the code libraries mentioned below.
Why do I still see & in the output, and where did my CDATA fields go?
Entities are not decoded, so Tom & Jerry arrives exactly like that. You can replace &, < and > afterwards with find-and-replace. Fields wrapped in CDATA are dropped entirely. To keep them, convert the CDATA to plain escaped text before uploading.
How do I convert XML to JSON in Python, JavaScript, C# or PowerShell?
In Python, the third-party xmltodict package parses XML into dictionaries that json.dumps can write out. In JavaScript or Node, npm packages such as fast-xml-parser or xml2js do the same. In C#, Json.NET offers JsonConvert.SerializeXmlNode. In PowerShell, you can load the file as [xml], select the nodes you need into objects and pipe them to ConvertTo-Json. These libraries handle namespaces, CDATA and nesting that this converter does not.
Can I get the XML into CSV or Excel instead?
Our XML to CSV conversion currently puts the whole record list into one cell, so it is not useful yet. A workaround is to convert to JSON here and open the file. Delete the outer {"library": wrapper and its final closing brace so the file starts with [ and ends with ]. Then run JSON to CSV, which gives one row per record with a header built from all keys. If accented characters look wrong in Excel, use Data, From Text/CSV and choose UTF-8, because that CSV has no BOM.
Is there a size limit for XML files?
Per file, the limit is 50 MB for guests, 100 MB with a free account, 200 MB on Plus and 1 GB on Pro. The whole file is loaded into memory at once, and data conversions are not part of the pay-once offer for very large files. For a huge export, split it into smaller files that each keep the root element.
What happens to my file, and who can see it?
Files travel over HTTPS through Cloudflare to our server. Your upload is deleted as soon as the conversion finishes. The converted file can be downloaded for about 4 hours, then it is deleted automatically. The download link is a random token that anyone holding it can use until then, so share it with care. File names, sizes and formats are logged for operations, and signed-in users keep a conversion history entry until they delete their account.