A library for working with the color formats defined by HTML and CSS.
Project Links
Meta
Author: James Bennett
Requires Python: >=3.9
Classifiers
Development Status
- 5 - Production/Stable
Environment
- Web Environment
Intended Audience
- Developers
License
- OSI Approved :: BSD License
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Topic
- Utilities
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:
>>> 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:
>>> import webcolors
>>> webcolors.html5_parse_legacy_color("chucknorris")
HTML5SimpleColor(red=192, green=0, blue=0)
Full documentation is available online.
Nov 11, 2024
24.11.1
Nov 11, 2024
24.11.0
Aug 10, 2024
24.8.0
Jun 06, 2024
24.6.0
Mar 27, 2023
1.13
May 26, 2022
1.12
Feb 17, 2020
1.11.1
Feb 17, 2020
1.11
Sep 09, 2019
1.10
Jun 08, 2019
1.9.1
Jun 02, 2019
1.9
Feb 12, 2018
1.8.1
Feb 09, 2018
1.8
Nov 25, 2016
1.7
Mar 18, 2015
1.5
Feb 10, 2012
1.4
Oct 24, 2009
1.3.1
May 08, 2009
1.3
Mar 01, 2009
1.2
Dec 19, 2008
1.1
Oct 29, 2008
1.0
Wheel compatibility matrix
Files in release
No dependencies