json2xml
Simple Python Library to convert JSON to XML
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 json2xmluv
uv add json2xmlpoetry
poetry add json2xmlInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
dicttoxmlConverts Python dictionaries and other native…
copyleft · top 5,000 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
parselParsel extracts data from HTML, JSON, and XML…
permissive · top 5,000 on PyPI
xmltojsonConverts XML documents to JSON format via a…
permissive · top 15,000 on PyPI
xmlunittestExtends Python's unittest framework to compare…
permissive · top 5,000 on PyPI
jinja2-cliA command-line interface for Jinja2 templating…
permissive · top 5,000 on PyPI
elementpathProvides XPath 1.0, 2.0, 3.0, and 3.1 selectors…
permissive · top 5,000 on PyPI
dict2xmlConverts Python dictionaries into XML strings…
permissive · top 5,000 on PyPI
jxmleaseConverts XML to Python data structures (lists,…
permissive · top 15,000 on PyPI
cloudmersive-convert-api-clientA Python client library for the Cloudmersive…
unclear · top 15,000 on PyPI