Skip to content
Free · Runs in your browser

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.

Works with
JSONJSONLXML

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
  • Arla Foods logo
  • Bacardi logo
  • British American Tobacco logo
  • Everest Detection logo
  • Golden Acre logo
  • Handlangers logo
  • Inspired Learning Group logo
  • Kantar logo
  • MUFG logo
  • NielsenIQ logo
  • PTI Digital logo
  • RethinkFirst logo
  • Starbucks logo
  • The Specialist Works logo
What you get

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 it works

How to convert JSON to XML

Each key becomes an element. A list becomes repeated elements, and an object becomes elements inside elements.

  1. 1

    Add your JSON

    Drop a .json file on the box, or paste the JSON.

  2. 2

    Pick the options

    Name the root element and list items, and choose whether @ keys become attributes.

  3. 3

    Download

    Save the .xml file, or copy the XML straight into your code.

Your options

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
Other ways

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.

Python with xmltodict
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.

How we handle your data

Once the page has loaded, it works with your internet switched off.

Every month

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.

Try Mammoth free

Weekly orders

Week 42orders-week-42.json
Week 43orders-week-43.json
Week 44orders-week-44.json
DriveDropboxOneDriveSFTP
All ordersUp to date
Oct 13Ana Costa129.50
Oct 15Ben Ellis48.00
Oct 21Chloé Martin310.25
Oct 28Dev Patel75.90
Oct 30O'Neill & Co1,200.00

Illustration. Every new file in the folder is added to the same table.

Questions

JSON to XML questions

Is my JSON uploaded anywhere?
No. The page reads the file and writes the XML inside your browser. Once the page has loaded, it works with your internet switched off.
What is the root element?
XML needs one element around everything else. If your JSON is one key holding an object, such as {"orders": {...}}, that key is the root. Otherwise the converter adds <root>, and you can rename it.
What happens to lists?
A list becomes the same element repeated: "tags": ["a", "b"] is <tags>a</tags><tags>b</tags>. A list with no name of its own, such as a list at the top of the file or a list inside a list, gets <item> elements, and you can rename those too.
How do I make an attribute?
Start the key with @: "@id": "1041" becomes id="1041" on its element, and "#text" becomes the element's text. Switch off @ keys as attributes to write every key as an element.
What happens to keys that are not valid XML names?
XML names cannot have spaces or most symbols, and cannot start with a digit. The converter swaps those characters for _ and puts _ in front of a leading digit, so "delivery note" becomes <delivery_note> and "2024" becomes <_2024>. The page lists what it renamed.
What about null, true and numbers?
null becomes an empty element, such as <note/>. Numbers and true/false are written as text, which is the only kind of value XML has.
Does it read JSON Lines?
Yes. Each line becomes one <item> under the root.
Is it free?
Yes, with no account and no email. Files can be up to 100 MB.