dict2xml
Small utility to convert a python dictionary into an XML string
What it is and what it does
dict2xml is a lightweight utility that serializes Python dictionaries into XML strings. It takes a dictionary as input and produces formatted XML output with control over element wrapping, indentation, and newline handling. The library offers a simple functional interface via dict2xml() and a more flexible Converter class for advanced use cases like custom key sorting, self-closing tags for specific values, and control over how arrays are wrapped.
The package has no external runtime dependencies, making it quick to install and integrate. It supports Python 3.5+ and has been in production use since 2012. Key limitations include no support for XML attributes, custom data type hooks, or XML declarations—it focuses on straightforward dictionary-to-XML conversion for data serialization tasks.
Use it for:
- Serialize application configuration dictionaries to XML for legacy systems or interoperability.
- Convert API response data structures into XML format for downstream processing or storage.
- Generate XML reports or data exports from Python data structures in batch jobs.
- Transform nested Python objects into XML for SOAP or XML-RPC communication.
- Export structured data from Python applications to XML-based workflows or tools.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Python dictionaries into XML strings with configurable formatting, wrapping, and tag behavior.
Yes. The package is lightweight, dependency-free, stable, and carries no known vulnerabilities. Install it if you need straightforward dictionary-to-XML conversion. Skip it if you require XML attributes, namespaces, or CDATA handling—those are documented limitations, not bugs.
Install
dict2xml on PyPI
pip
pip install dict2xmluv
uv add dict2xmlpoetry
poetry add dict2xmlInstalling dict2xml
Before you install
No runtime dependencies and a pure-Python wheel distribution make installation straightforward. The package is aging (last release 212 days ago) but remains actively maintained; the repository is not archived and the codebase is stable.
License in practice
MIT license permits commercial use, modification, and distribution with minimal restrictions, making it suitable for most projects.
Quickstart
from dict2xml import dict2xml
data = {'a': 1, 'b': [2, 3]}
result = dict2xml(data, wrap="root", indent=" ")
Verify before relying
- Whether the package handles deeply nested structures or very large dictionaries without performance degradation.
- Support for XML namespaces, attributes, or CDATA sections beyond what the description explicitly covers.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 212 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,094,040/month — #4,375 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dict2xml-1.7.8-py3-none-any.whl
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
javapropertiesReads and writes Java .properties files in both…
permissive · top 5,000 on PyPI
MarkupPyMarkupPy generates HTML and XML markup from…
permissive · top 5,000 on PyPI
xmljsonConverts XML documents to Python dictionaries…
permissive · top 5,000 on PyPI
tomli-wTomli-W serializes Python dictionaries to TOML…
permissive · top 1,000 on PyPI
xmlformatterFormats and compresses XML documents by…
permissive · top 15,000 on PyPI
dicttoxml2Converts Python dictionaries and native data…
copyleft · top 15,000 on PyPI
soup2dictConverts BeautifulSoup4 parsed HTML or XML…
permissive · top 15,000 on PyPI
xmltodictConverts XML to Python dictionaries and back,…
permissive · top 1,000 on PyPI
prettierfierReformats HTML and XML strings with intelligent…
permissive · top 15,000 on PyPI
data-to-xmlConverts Python dictionaries and lists into XML…
unclear · top 15,000 on PyPI