lxml is the most feature-rich
and easy-to-use library
for working with XML and HTML
in the Python language.


lxml is a Pythonic binding for the libxml2 and libxslt libraries. It is unique in that it combines the speed and feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the ElementTree API. See the introduction for more information about background and goals. Some common questions are answered in the FAQ.

This page describes the current stable version of lxml. See also the web page of the development version.


lxml.etree follows the ElementTree API as much as possible, building it on top of the native libxml2 tree. If you are new to ElementTree, start with the lxml.etree Tutorial. See also the ElementTree compatibility overview and the benchmark results comparing lxml to the original ElementTree and cElementTree implementations.

Right after the lxml.etree Tutorial and the ElementTree documentation, the most important place to look is the lxml.etree specific API documentation. It describes how lxml extends the ElementTree API to expose libxml2 and libxslt specific functionality, such as XPath, Relax NG, XML Schema, XSLT, and c14n. Python code can be called from XPath expressions and XSLT stylesheets through the use of extension functions. lxml also offers a SAX compliant API, that works with the SAX support in the standard library.

There is a separate module lxml.objectify that implements a data-binding API on top of lxml.etree. See the objectify and etree FAQ entry for a comparison.

In addition to the ElementTree API, lxml also features a sophisticated API for custom element classes. This is a simple way to write arbitrary XML driven APIs on top of lxml. As of version 1.1, lxml.etree has a new C-level API that can be used to efficiently extend lxml.etree in external C modules, including custom element class support.


The best way to download binary versions is to visit lxml at the Python Package Index. It has the source, eggs and installers for various platforms. The source distribution is signed with this key.

The latest version is lxml 1.3.6, released 2007-10-29 (changes for 1.3.6). Older versions are listed below.

Please take a look at the installation instructions!

It's also possible to check out the latest development version of lxml from svn directly, using a command like this:

svn co https://github.com/lxml/lxml/tree/master/trunk lxml

You can also browse it through the web. Please read how to build lxml from source first. The latest CHANGES of the developer version are also accessible. You can check there if a bug you found has been fixed or a feature you want has been implemented in the latest trunk version.

Mailing list

Questions? Suggestions? Code to contribute? We have a mailing list.

You can search the archive with Gmane or Google.

Bug tracker

lxml uses the launchpad bug tracker. If you are sure you found a bug in lxml, please file a bug report there. If you are not sure whether some unexpected behaviour of lxml is a bug or not, please ask on the mailing list first. Do not forget to search the archive (e.g. with Gmane)!


The lxml library is shipped under a BSD license. libxml2 and libxslt2 itself are shipped under the MIT license. There should therefore be no obstacle to using lxml in your codebase.

Old Versions