tree-sitter-css
CSS grammar for tree-sitter
What it is and what it does
tree-sitter-css is a language grammar module that plugs into the tree-sitter incremental parser framework to parse CSS code into syntax trees. It is not a standalone parser but rather a grammar definition that works with tree-sitter's core parsing engine, which must be installed separately. The package provides precompiled binaries for multiple platforms and Python versions, making it straightforward to add CSS parsing capabilities to Python applications that already use tree-sitter.
The grammar enables applications to parse CSS incrementally—updating only the parts of the syntax tree that changed when the source is edited—rather than reparsing the entire file. This is useful for code editors, linters, static analyzers, and other tools that need to understand CSS structure and maintain performance during interactive use.
Use it for:
- Build a CSS linter or formatter that understands the full syntax tree of stylesheets.
- Implement a code editor with incremental CSS parsing for real-time syntax highlighting and error detection.
- Analyze CSS codebases to extract selectors, properties, or dependencies for refactoring or auditing.
- Create a CSS-aware code transformation tool that modifies stylesheets while preserving structure.
- Develop a static analysis tool that detects CSS anti-patterns or unused rules.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a CSS grammar parser for tree-sitter, enabling incremental parsing and syntax tree analysis of CSS code.
Yes, if you are already using tree-sitter in your Python project and need to parse CSS. The package is well-maintained within the tree-sitter ecosystem, has no known vulnerabilities, and offers permissive licensing. Medium install friction is typical for compiled language bindings. Not worth installing if you need a standalone CSS parser or do not already have tree-sitter as a dependency.
Install
tree-sitter-css on PyPI
pip
pip install tree-sitter-cssuv
uv add tree-sitter-csspoetry
poetry add tree-sitter-cssInstalling tree-sitter-css
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (x86_64, ARM, Windows). Requires Python 3.10+. Package is aging (320 days since last release) but shows no signs of abandonment.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install tree-sitter-css
from tree_sitter import Language, Parser
# Load the CSS grammar and create a parser
CSS_LANGUAGE = Language('path/to/tree_sitter_css.so', 'css')
parser = Parser()
parser.set_language(CSS_LANGUAGE)
# Parse CSS code
tree = parser.parse(b'body { color: red; }')
Requires tree-sitter core library and language bindings installed separately; Python 3.10 or later required.
Verify before relying
- Whether tree-sitter core library is automatically installed as a dependency or must be installed separately.
- Specific tree-sitter API version compatibility for this grammar release.
- Performance characteristics for large CSS files or real-time parsing scenarios.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 320 days since the last release |
| First released | |
| Downloads | 2,074,204/month — #3,319 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_css-0.25.0-cp310-abi3-macosx_10_9_x86_64.whl; tree_sitter_css-0.25.0-cp310-abi3-macosx_11_0_arm64.whl; tree_sitter_css-0.25.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tree_sitter_css-0.25.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_css-0.25.0-cp310-abi3-musllinux_1_2_aarch64.whl; tree_sitter_css-0.25.0-cp310-abi3-musllinux_1_2_x86_64.whl; tree_sitter_css-0.25.0-cp310-abi3-win_amd64.whl; tree_sitter_css-0.25.0-cp310-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, css
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-htmlProvides an HTML grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-cProvides a C language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-jsonProvides a JSON grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-javascriptProvides a JavaScript and JSX parser grammar…
permissive · top 5,000 on PyPI
tree-sitter-powershellProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI
tree-sitter-c-sharpProvides a C# language parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-regexProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI