tinycss2
A tiny CSS parser
Decision gist · record as of 2026-08-14
Yes. tinycss2 is a stable, actively maintained library with low install friction, permissive licensing, and no known vulnerabilities. It fills a specific niche—low-level CSS parsing without semantic enforcement—making it the right choice if you need to parse or generate CSS syntax programmatically. Install it if your project requires CSS tokenization or syntax manipulation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; tested on CPython and PyPy.
- Low install friction with a single runtime dependency (webencodings).
- The package is actively maintained with a recent commit on 2026-06-21 and has been in production use since 2013.
License · maintenance · safety
permissive license (permissive) — BSD license (permissive) means you can use, modify, and distribute tinycss2 freely in commercial and private projects with minimal restrictions.
last release 2025-11-23 (264 days) · last repo commit 2026-06-21 · 190 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 113,205,802 downloads/mo, #317 on PyPI
Alternatives
Verify before relying
pip install tinycss2
import tinycss2
tokens = tinycss2.parse_declaration_list('color: red; margin: 0')
for token in tokens:
print(token)- Whether tinycss2 can parse CSS from external files or only from strings
- Performance characteristics when parsing large or complex CSS documents
- Whether the package provides utilities for CSS validation or only parsing/generation
What it is and what it does
tinycss2 is a low-level CSS parser that converts CSS strings into structured token and block objects according to the CSS Syntax Level 3 specification. It does not enforce CSS module-specific rules or properties—it understands the grammar of CSS itself but leaves semantic validation to higher-level tools. The package also generates CSS strings from these objects, making it useful as a foundation for CSS processing pipelines.
The library is designed for developers who need to inspect, manipulate, or regenerate CSS at the syntactic level. Its single runtime dependency (webencodings) keeps installation lightweight, and it supports Python 3.10+ on both CPython and PyPy. Active maintenance and a 13-year history suggest it is stable and suitable for production use.
Use it for
- Build CSS preprocessors or linters that need to parse and analyze CSS syntax without enforcing specific properties
- Generate CSS dynamically from Python objects or data structures
- Extract tokens from CSS to inspect selectors, declarations, or at-rules for analysis or transformation
- Implement CSS minifiers or formatters that operate on the token level
- Parse CSS in web scraping or HTML processing pipelines to extract styling information
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
tinycss2 is a stable, actively maintained library with low install friction, permissive licensing, and no known vulnerabilities. It fills a specific niche—low-level CSS parsing without semantic enforcement—making it the right choice if you need to parse or generate CSS syntax programmatically. Install it if your project requires CSS tokenization or syntax manipulation.
Install
tinycss2 on PyPI
Before you install
Low install friction with a single runtime dependency (webencodings). The package is actively maintained with a recent commit on 2026-06-21 and has been in production use since 2013.
Requires Python 3.10 or later; tested on CPython and PyPy.
License in practice
BSD license (permissive) means you can use, modify, and distribute tinycss2 freely in commercial and private projects with minimal restrictions.
Quickstart
pip install tinycss2
import tinycss2
tokens = tinycss2.parse_declaration_list('color: red; margin: 0')
for token in tokens:
print(token)
Verify before relying
- Whether tinycss2 can parse CSS from external files or only from strings
- Performance characteristics when parsing large or complex CSS documents
- Whether the package provides utilities for CSS validation or only parsing/generation
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagewebencodings |
| Maintenance | Actively maintained 264 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 113,205,802 / month, #317 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 :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming 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 :: PyPyTopic :: Text Processing |
Evidence: tinycss2-1.5.1-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 parser python”
- tinycss2tinycss2 parses CSS strings into token and block objects, and…
- tree-sitter-cssProvides a CSS grammar parser for tree-sitter, enabling incremental…
- cssutilscssutils parses and builds CSS stylesheets as a DOM structure without…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
Provides Python bindings to the Brotli compression library, enabling lossless compression and decompression using a modern LZ77 variant with Huffman coding and context modeling.
Install it if you need Brotli compression in Python; the API is straightforward and the library is battle-tested.
See also cssselect2 · tinyhtml5 · tree-sitter-css · cssutils · pyphen · weasyprint · cssselect · md2pdf · django-premailer · pygmars