skillfed

dict2xml

Small utility to convert a python dictionary into an XML string

dict2xml v1.7.8 1.1M downloads/30d#4,375 on PyPI33
Permissive license MIT AGING released

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 dict2xml

uv

uv add dict2xml

poetry

poetry add dict2xml

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: XML

Tags

dictionary to xml conversionpython dict xml serializationconvert dict to xml stringxml generation from pythondict xml formatterpython data to xml
xml-serializationdata-conversion

More Python Modules packages