EUComply

How to Convert XML to JSON

September 2026 · 4 min read · Try it in your browser →

Legacy APIs, RSS feeds, SOAP responses, Maven and .NET config files — XML is still everywhere, and almost every modern tool wants JSON. Here's how to convert it without hand-writing a parser.

Option 1: The Transmute CLI (free)

transmute parses XML records into JSON directly. Given this file (users.xml):

<data>
  <user><name>Alice</name><age>32</age></user>
  <user><name>Bob</name><age>25</age></user>
</data>

run:

$ npx github:mahope/transmute users.xml --format xml --pipe '[{"op":"head","n":10}]' --output json
[
  {
    "name": "Alice",
    "age": "32"
  },
  {
    "name": "Bob",
    "age": "25"
  }
]

You can chain operations in the same pass — here filtering and reshaping before output:

$ npx github:mahope/transmute users.xml --format xml     --pipe '[{"op":"filter","expr":"Number(item.age) > 26"},{"op":"pick","fields":["name"]}]'     --output json
[
  {
    "name": "Alice"
  }
]

Option 2: Python

import xmltodict, json
with open("users.xml") as f:
    data = xmltodict.parse(f.read())
print(json.dumps(data, indent=2))

pip install xmltodict. Solid, but it's another dependency to pin, and attributes get @-prefixed keys you often have to clean up afterwards.

Option 3: In your browser

For a quick one-off, the live demo on the Transmute page converts between formats entirely client-side — nothing is uploaded.

Caveats worth knowing

Pipelines like this — without writing a script

The Transmute CLI is free (npx github:mahope/transmute). The desktop app adds an interactive pipeline builder, live preview and batch processing — one-time $19, no subscription.

Try the live demo →   See pricing