lxml
Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Decision gist · record as of 2026-08-14
Yes. lxml is a stable, actively maintained library with no known vulnerabilities, permissive licensing, and broad platform support. The medium install friction (compiled extensions) is offset by prebuilt wheels and is standard for performance-critical XML work. Install it if you need robust XML/HTML parsing, validation, or transformation; avoid it only if you must stay pure-Python and can accept slower performance.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a C compiler and development headers for libxml2/libxslt if building from source; prebuilt wheels available for Python 3.8–3.14 on common platforms.
- Medium install friction due to compiled C extensions; prebuilt wheels are available for common platforms (macOS, Linux, Windows across multiple architectures), but building from source requires Cython.
- Maintenance is active with recent commits and regular releases.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use, modify, and distribute lxml in commercial and proprietary projects with minimal restrictions, provided you include the license text.
last release 2026-05-18 (88 days) · last repo commit 2026-08-13 · 3,045 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 416,832,024 downloads/mo, #102 on PyPI
Alternatives
Verify before relying
pip install lxml
from lxml import etree
root = etree.fromstring(b'<root><child>text</child></root>')
print(root[0].text)- Whether the xlink:href fix in 6.1.1 addresses all known HTML sanitization bypass vectors or if additional hardening is recommended for security-sensitive use.
- Performance characteristics and memory overhead compared to pure-Python XML libraries for large document processing.
What it is and what it does
lxml is a mature, production-grade XML and HTML processing library that wraps libxml2 and libxslt with a Pythonic ElementTree-compatible interface. It provides full support for XPath queries, XSLT transformations, XML Schema and RelaxNG validation, and C14N canonicalization, making it suitable for both simple document parsing and complex XML workflows.
The library is actively maintained and widely used (top 1000 on PyPI). It requires compilation of C extensions but ships prebuilt wheels for most platforms and Python versions. Recent updates have addressed security issues in link attribute handling and underlying libxslt vulnerabilities, making it a reliable choice for production XML processing where performance and standards compliance matter.
Use it for
- Parse and extract data from XML or HTML documents using XPath expressions for targeted element selection.
- Validate XML documents against schemas (XSD) or RelaxNG grammars before processing.
- Transform XML documents using XSLT stylesheets for format conversion or data extraction.
- Build or modify XML/HTML documents programmatically and serialize them back to strings or files.
- Sanitize or normalize HTML content while preserving structure and handling embedded SVG/MathML safely.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
lxml is a stable, actively maintained library with no known vulnerabilities, permissive licensing, and broad platform support. The medium install friction (compiled extensions) is offset by prebuilt wheels and is standard for performance-critical XML work. Install it if you need robust XML/HTML parsing, validation, or transformation; avoid it only if you must stay pure-Python and can accept slower performance.
Install
lxml on PyPI
Before you install
Medium install friction due to compiled C extensions; prebuilt wheels are available for common platforms (macOS, Linux, Windows across multiple architectures), but building from source requires Cython. Maintenance is active with recent commits and regular releases.
Requires a C compiler and development headers for libxml2/libxslt if building from source; prebuilt wheels available for Python 3.8–3.14 on common platforms.
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute lxml in commercial and proprietary projects with minimal restrictions, provided you include the license text.
Quickstart
pip install lxml
from lxml import etree
root = etree.fromstring(b'<root><child>text</child></root>')
print(root[0].text)
Verify before relying
- Whether the xlink:href fix in 6.1.1 addresses all known HTML sanitization bypass vectors or if additional hardening is recommended for security-sensitive use.
- Performance characteristics and memory overhead compared to pure-Python XML libraries for large document processing.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 88 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 416,832,024 / month, #102 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyOperating System :: OS IndependentProgramming Language :: CProgramming Language :: CythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: HTMLTopic :: Text Processing :: Markup :: XML |
Evidence: lxml-6.1.1-cp310-cp310-macosx_10_9_universal2.whl; lxml-6.1.1-cp310-cp310-macosx_10_9_x86_64.whl; lxml-6.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; lxml-6.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; lxml-6.1.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; lxml-6.1.1-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl; lxml-6.1.1-cp310-cp310-manylinux_2_28_i686.whl; lxml-6.1.1-cp310-cp310-manylinux_2_31_armv7l.whl; lxml-6.1.1-cp310-cp310-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl; lxml-6.1.1-cp310-cp310-musllinux_1_2_aarch64.whl; lxml-6.1.1-cp310-cp310-musllinux_1_2_armv7l.whl; lxml-6.1.1-cp310-cp310-musllinux_1_2_riscv64.whl; lxml-6.1.1-cp310-cp310-musllinux_1_2_x86_64.whl; lxml-6.1.1-cp310-cp310-win32.whl; lxml-6.1.1-cp310-cp310-win_amd64.whl; lxml-6.1.1-cp310-cp310-win_arm64.whl; lxml-6.1.1-cp311-cp311-macosx_10_9_universal2.whl; lxml-6.1.1-cp311-cp311-macosx_10_9_x86_64.whl; lxml-6.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; lxml-6.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “xslt transformation”
- lxmllxml provides Python bindings to libxml2 and libxslt, enabling…
- saxoncheSaxonC-HE is a Python wrapper for Saxon, an XML processor that runs…
- django-revproxyA Django application that forwards HTTP requests to another server…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also elementpath · xmlunittest · saxonche · cssselect · pyquery · cssselect2 · lxml-html-clean · json2xml · pykml · cybox