xmltojson
A Python module and cli tool to quickly convert xml text or files into json
What it is and what it does
xmltojson is a lightweight Python library that converts XML documents into JSON strings. It wraps xmltodict to provide both a programmatic API and a command-line interface for the conversion task. The library supports reading XML from files, stdin, or direct strings, and can write output to stdout or to a file.
The package is intended for developers who need to transform XML data into JSON format as part of data processing pipelines or integration workflows. It supports Python 3.7 through 3.11 and is marked as production-stable, though development activity has slowed since its last release in October 2024.
Use it for:
- Convert XML configuration files to JSON for use in modern web applications or APIs
- Transform XML data exports from legacy systems into JSON for downstream processing
- Batch convert XML documents via the command-line tool in shell scripts or CI/CD pipelines
- Parse XML responses from SOAP or REST services and re-serialize as JSON
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts XML documents to JSON format via a Python library or command-line tool, using xmltodict as its underlying parser.
Yes, if you need straightforward XML-to-JSON conversion. The package has low install friction, no known vulnerabilities, and permissive licensing. The dormant maintenance status is acceptable for a stable, single-purpose tool, but verify that its JSON output format (which depends on xmltodict's behavior) matches your structural requirements before committing to it.
Install
xmltojson on PyPI
pip
pip install xmltojsonuv
uv add xmltojsonpoetry
poetry add xmltojsonInstalling xmltojson
Before you install
Low install friction with a single lightweight runtime dependency. Maintenance is dormant—last release was in October 2024, but the repository remains active and unarchived with no recent commits.
License in practice
Licensed under Apache-2.0 (permissive), allowing use in commercial and private projects with minimal restrictions.
Quickstart
import xmltojson
with open('file.xml', 'r') as f:
xml_content = f.read()
result = xmltojson.parse(xml_content)
print(result)
Verify before relying
- Whether the library preserves XML attributes, namespaces, or other structural metadata in the JSON output
- Performance characteristics on large XML files or deeply nested structures
- Whether round-trip conversion (JSON back to XML) is supported
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<4.0,>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — xmltodict |
| Maintenance | dormant — 663 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 583,420/month — #5,893 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xmltojson-2.0.3-py3-none-any.whl
Keywords: json, xml, convert, converter, library
Tags
More XML packages
Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
defusedxmlDefusedxml hardens Python's standard XML…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
xmltodictConverts XML to Python dictionaries and back,…
permissive · top 1,000 on PyPI
SphinxSphinx generates professional documentation…
permissive · top 1,000 on PyPI
jcConverts output from popular CLI tools,…
permissive · top 15,000 on PyPI
xmljsonConverts XML documents to Python dictionaries…
permissive · top 5,000 on PyPI
cfn-flipConverts AWS CloudFormation templates between…
permissive · top 5,000 on PyPI
soup2dictConverts BeautifulSoup4 parsed HTML or XML…
permissive · top 15,000 on PyPI
json2xmlConverts JSON data to XML format via Python…
permissive · top 15,000 on PyPI
data-to-xmlConverts Python dictionaries and lists into XML…
unclear · top 15,000 on PyPI
types-xmltodictProvides type annotations for the xmltodict…
permissive · top 5,000 on PyPI
yqyq is a command-line processor that applies jq…
permissive · top 5,000 on PyPI
jxmleaseConverts XML to Python data structures (lists,…
permissive · top 15,000 on PyPI