skillfed

json2xml

Simple Python Library to convert JSON to XML

json2xml v6.5.1 328.9K downloads/30d#7,550 on PyPI109
Permissive license Apache Software License 2.0 Active released

What it is and what it does

json2xml is a Python library and command-line tool for converting JSON data into XML. It handles JSON strings, files, and API responses, producing XPath 3.1 compatible output. The library was originally built on dict2xml but has since integrated that functionality directly, adding type hints, tests, and performance improvements.

The package offers both a pure Python implementation and an optional Rust extension for acceleration. The pure Python path runs on all supported platforms and versions; the Rust extension is automatically used when available and falls back to Python when a feature isn't natively supported. It depends on defusedxml for secure XML handling and urllib3 for URL fetching, with built-in protections against private network access and oversized responses.

Use it for:

  • Convert JSON API responses to XML when downstream systems or legacy services require XML input.
  • Batch-convert JSON files to XML from the command line using the json2xml-py CLI tool.
  • Process JSON data from URLs in Python with automatic security controls (no redirects, private network rejection by default).
  • Generate XPath 3.1 compliant XML output for standards-based XML processing pipelines.
  • Accelerate high-volume JSON-to-XML conversion with the optional Rust extension for latency-sensitive applications.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts JSON data to XML format via Python library or CLI tool, with optional Rust acceleration for performance-critical workloads.

Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a focused problem well. The permissive Apache 2.0 license imposes no restrictions. The optional Rust acceleration is a genuine performance option for throughput-critical work, but the pure Python fallback ensures broad compatibility. Suitable for both library integration and CLI scripting.

Install

json2xml on PyPI

pip

pip install json2xml

uv

uv add json2xml

poetry

poetry add json2xml

Installing json2xml

Before you install

Low friction installation with a pure Python fallback path. Actively maintained with a release 10 days old; supports modern Python versions (3.10–3.14) and PyPy. Optional Rust extension available for performance-sensitive use.

License in practice

Licensed under Apache Software License 2.0 (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

pip install json2xml

from json2xml import json2xml
from json2xml.utils import readfromstring

data = readfromstring('{"name": "Ada", "language": "Python"}')
print(json2xml.Json2xml(data).to_xml())

Requires Python 3.10 or later.

Verify before relying

  • Whether the Rust extension (json2xml[fast]) is available for all target platforms or only specific architectures.
  • Actual performance gains on typical workloads in production environments versus the benchmark figures cited.

Package facts

License Apache Software License 2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — defusedxml, urllib3
Maintenance actively maintained — 10 days since the last release
Last repo commit
First released
Downloads 328,914/month — #7,550 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: json2xml-6.5.1-py3-none-any.whl

Keywords: json2xml

Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

json to xml conversionjson xml serializationcli json xml toolpython json xml libraryapi response xml conversionjson file to xmlxpath 3.1 compatible xml
data-format-conversioncli-toolrust-accelerated

More Python Modules packages