XML to JSON
Convert XML to readable JSON: attributes become @name keys, text beside them #text, and repeated elements lists. Namespaces and CDATA are kept, and DOCTYPE entities are never expanded.
Tip: choose several files at once to process them all with the same settings.
How to use it
- 1Choose or drop an XML file, or paste the XML.
- 2Choose whether repeated elements are always lists, and whether to indent.
- 3Copy the JSON or download it as a .json file.
Frequently asked questions
How are XML attributes written in JSON?
An attribute becomes a key starting with @, such as @id. Text in an element that also has attributes or child elements goes under #text, and an element with only text becomes that text.
Why is an element sometimes a list and sometimes not?
By default an element becomes a list only when it appears more than once in the same place. Choose Always a list if your code needs the same shape every time.
What happens to namespaces and CDATA?
Namespace prefixes stay in the names, such as soap:Body, and CDATA sections are read as plain text.
Is it safe to open an XML file someone sent me?
Yes. DOCTYPE declarations are skipped and their entities are never expanded, so tricks like the billion laughs attack do nothing.
Related tools
- Excel to CSVTurn an Excel sheet (XLSX, XLS or ODS) into CSV, or every sheet at once.
- CSV to ExcelTurn a CSV file into an Excel sheet without losing leading zeros or long numbers.
- CSV to JSONTurn a CSV table into JSON: one object for each row, named by the header.
- JSON to CSVTurn JSON data, API responses or JSON Lines into a CSV table.