JSON to XML converter
Turn JSON into well-formed XML in your browser. Keys that are not valid XML names are fixed for you, so the file opens in any XML reader.
Drop a JSON file here
A .json or JSON Lines file, up to 100 MB. Its contents stay on your computer.
- No sign-up
- No content uploaded
- Always valid XML
XML that every parser accepts.
Your file stays on your computer
The JSON is read and the XML is written in your browser. Its contents are never sent to Mammoth or anyone else.
Keys made into valid names
A key such as "delivery note" or "2026" becomes delivery_note or _2026, and the page tells you which.
Attributes from @ keys
Keys that start with @ become attributes, and "#text" becomes the element's text.
How to convert JSON to XML
Each key becomes an element. A list becomes repeated elements, and an object becomes elements inside elements.
- 1
Add your JSON
Drop a .json file on the box, or paste the JSON.
- 2
Pick the options
Name the root element and list items, and choose whether @ keys become attributes.
- 3
Download
Save the .xml file, or copy the XML straight into your code.
Other ways to do it
Python's xmltodict can write XML from JSON too. The difference is what happens to keys XML does not allow.
Python with xmltodict
A script that runs every day
- Fixes keys XML cannot useNo
- Takes a list at the topNo
- Attributes from @ keysYes
- No code to writeNo
- This page
This converter
Valid XML in one step
- Fixes keys XML cannot useYes
- Takes a list at the topYes
- Attributes from @ keysYes
- No code to writeYes
How to convert JSON to XML in Python
The xmltodict library writes XML from a Python dictionary, and the json module reads the file. Here is the whole script.
Going the other way? The XML to JSON converter reads the same @ and #text keys. Need a table instead? Use the JSON to Excel converter.
import json
import xmltodict
with open("orders.json") as f:
data = json.load(f)
with open("orders.xml", "w") as f:
f.write(xmltodict.unparse(data, pretty=True))The JSON needs one key at the top, which becomes the root element. Rename keys that have spaces or start with a digit first, or the XML will not open.
Your file stays private
The converter runs inside this page. Your JSON is read and turned into XML on your computer, and its contents are never sent to Mammoth. We record only what kind of data it was, such as orders, and its common field names, never a value.
Once the page has loaded, it works with your internet switched off.
Sending XML to another system every week?
Mammoth can take it from there. Put each week's JSON file in a folder and Mammoth reads it into one table, then saves it as XML to SFTP, SharePoint or OneDrive on a schedule.
Weekly orders
| Week 42 | Oct 13 | Ana Costa | 129.50 | |
| Week 42 | Oct 15 | Ben Ellis | 48.00 | |
| Week 43 | Oct 21 | Chloé Martin | 310.25 | |
| Week 44 | Oct 28 | Dev Patel | 75.90 | |
| Week 44 | Oct 30 | O'Neill & Co | 1,200.00 |
Illustration. Every new file in the folder is added to the same table.