whatisgithub

What is xmltodict?

martinblech/xmltodict — explained in plain English

Analysis updated 2026-06-26

5,735PythonAudience · developerComplexity · 1/5LicenseSetup · easy

In one sentence

xmltodict is a tiny Python library that converts XML documents into Python dictionaries and back, making XML data as easy to navigate and modify as JSON with no extra dependencies.

Mindmap

mindmap
  root((xmltodict))
    What it does
      XML to dict
      Dict to XML
      Stream large files
    Conversion rules
      Elements as keys
      Attributes with prefix
      Repeated items as list
    Features
      Namespace support
      No extra dependencies
      Streaming mode
    Install
      pip install
      Pure Python
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Parse an XML API response into a Python dictionary so you can access nested fields and attributes like any other Python data.

USE CASE 2

Process a large XML data dump using streaming mode to avoid loading the entire file into memory.

USE CASE 3

Round-trip XML: read an XML config file, modify values as a Python dict, then write it back as valid XML.

USE CASE 4

Convert legacy SOAP or RSS XML responses into Python dictionaries for easier data processing.

What is it built with?

Pythonpip

How does it compare?

martinblech/xmltodictandrewyng/translation-agentklavis-ai/klavis
Stars5,7355,7355,734
LanguagePythonPythonPython
Setup difficultyeasyeasymoderate
Complexity1/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
MIT, use freely for any purpose including commercial projects.

So what is it?

xmltodict is a Python library that converts XML documents into Python dictionaries, making XML data easier to work with in code. XML is an older data format that uses angle-bracket tags to organize information, while a Python dictionary is a simpler key-value structure that most Python code already knows how to handle. The library bridges the two by parsing an XML document and producing a dictionary that mirrors its structure. The conversion follows a predictable set of rules. XML element names become dictionary keys. Repeated elements at the same level become a list. XML attributes are stored in the same dictionary with an @ prefix so they are easy to spot and separate from element content. Text content inside an element is stored under a key called #text. This consistent mapping means you can navigate the resulting dictionary the same way you would navigate any other Python data structure. The library also supports going the other direction. You can call its unparse function on a dictionary and get back a valid XML document. This makes it possible to read an XML file, modify the data as a dictionary, and write it back out as XML without using a heavier XML processing library. For large XML files, such as data dumps from Wikipedia or similar sources, the library includes a streaming mode. Instead of loading the entire file into memory at once, it calls a function you provide for each item at a specified depth in the document. This allows processing very large XML files without running out of memory. Installation is through pip. The library is small, written in pure Python, and has no required dependencies beyond the standard library's built-in XML parser. It supports XML namespaces, with options to expand them, collapse them to short prefixes, or ignore them entirely.

Copy-paste prompts

Prompt 1
Parse this XML API response with xmltodict in Python and show me how to access nested elements and XML attributes.
Prompt 2
Use xmltodict streaming mode to process a large Wikipedia XML dump and extract all article titles without running out of memory.
Prompt 3
Convert a Python dictionary back to XML using xmltodict.unparse() and write the result to a file.
Prompt 4
How does xmltodict handle repeated XML elements at the same level, does it produce a list or overwrite the key?

Frequently asked questions

What is xmltodict?

xmltodict is a tiny Python library that converts XML documents into Python dictionaries and back, making XML data as easy to navigate and modify as JSON with no extra dependencies.

What language is xmltodict written in?

Mainly Python. The stack also includes Python, pip.

What license does xmltodict use?

MIT, use freely for any purpose including commercial projects.

How hard is xmltodict to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is xmltodict for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.