cssselect
cssselect parses CSS3 Selectors and translates them to XPath 1.0
Decision gist · record as of 2026-08-14
Yes. cssselect is a stable, actively maintained library with zero security vulnerabilities, low install friction, and permissive licensing. It solves a real problem—enabling CSS selector syntax in XPath-based document queries—and is already widely adopted (top 1000 PyPI packages). Install it if you need to translate CSS selectors to XPath for lxml or similar engines.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low install friction; pure Python wheel with no runtime dependencies.
- Actively maintained with a recent release 18 days ago and ongoing commits.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows free use, modification, and distribution with minimal restrictions.
last release 2026-07-27 (18 days) · last repo commit 2026-08-09 · 309 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 24,049,380 downloads/mo, #927 on PyPI
Alternatives
Verify before relying
pip install cssselect
from cssselect import GenericTranslator
translator = GenericTranslator()
xpath = translator.css_to_xpath('div.content > p')
print(xpath) # XPath expression for use with lxml or similar- Specific CSS3 selector features supported or unsupported beyond the W3C spec reference
- Performance characteristics when translating large or complex selector expressions
- Compatibility guarantees with specific XPath engine implementations beyond lxml
What it is and what it does
cssselect is a Python library that converts CSS3 selector syntax into XPath 1.0 expressions. It acts as a bridge between the familiar CSS selector syntax used in browsers and the XPath query language supported by XML/HTML parsing engines. The library takes a CSS selector string and produces an equivalent XPath expression that can be executed against a document tree using lxml or any other XPath-capable engine.
The package has no runtime dependencies and installs as a pure Python wheel, making it lightweight and easy to integrate. It's actively maintained, supports Python 3.10 through 3.14, and is widely used in web scraping and document parsing workflows where CSS selector syntax is more intuitive than raw XPath but XPath execution is required.
Use it for
- Convert CSS selectors to XPath for querying HTML/XML with lxml when CSS selector support is unavailable
- Build web scrapers that accept CSS selector syntax from users and execute them via XPath engines
- Translate browser-style CSS selectors into XPath for server-side document parsing and testing
- Integrate CSS selector parsing into tools that need to support both CSS and XPath query languages
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
cssselect is a stable, actively maintained library with zero security vulnerabilities, low install friction, and permissive licensing. It solves a real problem—enabling CSS selector syntax in XPath-based document queries—and is already widely adopted (top 1000 PyPI packages). Install it if you need to translate CSS selectors to XPath for lxml or similar engines.
Install
cssselect on PyPI
Before you install
Low install friction; pure Python wheel with no runtime dependencies. Actively maintained with a recent release 18 days ago and ongoing commits.
Requires Python 3.10 or later.
License in practice
BSD-3-Clause permissive license allows free use, modification, and distribution with minimal restrictions.
Quickstart
pip install cssselect
from cssselect import GenericTranslator
translator = GenericTranslator()
xpath = translator.css_to_xpath('div.content > p')
print(xpath) # XPath expression for use with lxml or similar
Verify before relying
- Specific CSS3 selector features supported or unsupported beyond the W3C spec reference
- Performance characteristics when translating large or complex selector expressions
- Compatibility guarantees with specific XPath engine implementations beyond lxml
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 18 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 24,049,380 / month, #927 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersProgramming 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 :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: cssselect-1.5.0-py3-none-any.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 › “css selector to xpath”
- cssselectcssselect parses CSS3 selectors and translates them to XPath 1.0…
- parselParsel extracts data from HTML, JSON, and XML documents using CSS…
- requests-htmlParses and scrapes HTML from web pages using a simple, intuitive API…
Give your agent the search over MCP, or paste the wish link into any chat.
More HTML packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Beautiful Soup parses HTML and XML documents into a navigable tree, providing Pythonic methods to search, iterate, and modify the parsed content.
Install it if you need to parse or extract data from markup documents.
lxml provides Python bindings to libxml2 and libxslt, enabling parsing, validation, and transformation of XML and HTML documents through an ElementTree-compatible API with support for XPath, XSLT, and schema validation.
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.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
Converts Markdown text to HTML using a Python implementation of John Gruber's Markdown specification, with support for extensions.
Install it if you need to parse Markdown in Python.
See also elementpath · parsel · pyquery · selectolax · turbohtml · cssutils · cssselect2 · soupsieve · requests-html · itemloaders