Skip to main content

A library for working with the color formats defined by HTML and CSS.

Project description

CI status image

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webcolors-25.10.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webcolors-25.10.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file webcolors-25.10.0.tar.gz.

File metadata

  • Download URL: webcolors-25.10.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.13.0

File hashes

Hashes for webcolors-25.10.0.tar.gz
Algorithm Hash digest
SHA256 62abae86504f66d0f6364c2a8520de4a0c47b80c03fc3a5f1815fedbef7c19bf
MD5 a825ed84ce2ada0d9271a54b0adc8e7b
BLAKE2b-256 1d7aeb316761ec35664ea5174709a68bbd3389de60d4a1ebab8808bfc264ed67

See more details on using hashes here.

File details

Details for the file webcolors-25.10.0-py3-none-any.whl.

File metadata

  • Download URL: webcolors-25.10.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.13.0

File hashes

Hashes for webcolors-25.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 032c727334856fc0b968f63daa252a1ac93d33db2f5267756623c210e57a4f1d
MD5 5c7471af1f8263c8e822c0807d14c973
BLAKE2b-256 e2cce097523dd85c9cf5d354f78310927f1656c422bd7b2613b2db3e3f9a0f2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page