webcolors
A library for working with the color formats defined by HTML and CSS.
Install
webcolors on PyPI
pip
pip install webcolorsuv
uv add webcolorspoetry
poetry add webcolorsPackage 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 — 286 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: webcolors-25.10.0-py3-none-any.whl
Keywords: color, css, html, web
About webcolors
from the package's own PyPI description — quoted content, verbatim
.. --restructuredtext--
.. image:: https://github.com/ubernostrum/webcolors/workflows/CI/badge.svg :alt: CI status image :target: https://github.com/ubernostrum/webcolors/actions?query=workflow%3ACI
webcolors is a module for working with and converting between the
various HTML/CSS color formats.
Support is included for normalizing and converting between the
following formats (RGB colorspace only; conversion to/from HSL can be
handled by the colorsys module in the Python standard library):
-
Specification-defined color names
-
Six-digit hexadecimal
-
Three-digit hexadecimal
-
Integer
rgb()triplet -
Percentage
rgb()triplet
For example:
.. code-block:: python
>>> import webcolors
>>> webcolors.hex_to_name("#daa520")
'goldenrod'
Implementations are also provided for the HTML5 color parsing and
serialization algorithms. For example, parsing the infamous
"chucknorris" string into an rgb() triplet:
.. code-block:: python
>>> import webcolors
>>> webcolors.html5_parse_legacy_color("chucknorris")
HTML5SimpleColor(red=192, green=0, blue=0)
Full documentation is available online <https://webcolors.readthedocs.io/>_.
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
webcolors converts between HTML/CSS color formats including hex, rgb(), and named colors, with support for HTML5 color parsing algorithms.
Installs with no runtime dependencies and carries active maintenance; the repository shows recent commits and the package is marked Production/Stable.
BSD-3-Clause is a permissive license that allows commercial and private use with minimal restrictions, requiring only attribution and inclusion of the license text.
Usage
pip install webcolors==25.10.0
import webcolors
webcolors.hex_to_name("#daa520")
# Returns: 'goldenrod'
Requires Python 3.10 or later.
Verdict: A lightweight, zero-dependency color-format utility with stable history since 2008, active maintenance, and no known vulnerabilities. Safe for production use in web applications needing HTML/CSS color handling.
Needs verification
- Whether the package's color-name database is complete and current with the latest CSS/HTML specifications.
- Performance characteristics when parsing large batches of color values.
Similar packages
permissive · top 1,000 on PyPI
colorlogpermissive · top 1,000 on PyPI
pytesseractpermissive · top 1,000 on PyPI
weasyprintpermissive · top 1,000 on PyPI
tinyhtml5permissive · top 1,000 on PyPI
futurepermissive · top 1,000 on PyPI
tinycss2permissive · top 1,000 on PyPI
html5libpermissive · top 1,000 on PyPI
soupsievepermissive · top 100 on PyPI
jupyterlab-pygmentspermissive · top 1,000 on PyPI