#ansi #hsl #rgb #color

no-std coolor

conversion between color formats

10 releases (5 breaking)

0.6.0 Aug 16, 2023
0.5.1 Dec 15, 2022
0.5.0 Mar 19, 2022
0.4.0 Mar 14, 2022
0.1.1 Nov 11, 2021

#27 in No standard library

Download history 14925/week @ 2023-06-04 17170/week @ 2023-06-11 15450/week @ 2023-06-18 11835/week @ 2023-06-25 11553/week @ 2023-07-02 15771/week @ 2023-07-09 14611/week @ 2023-07-16 15432/week @ 2023-07-23 16034/week @ 2023-07-30 15310/week @ 2023-08-06 14545/week @ 2023-08-13 23084/week @ 2023-08-20 18808/week @ 2023-08-27 18010/week @ 2023-09-03 13648/week @ 2023-09-10 11289/week @ 2023-09-17

64,264 downloads per month
Used in 53 crates (3 directly)

MIT and LGPL-3.0-or-later


MIT Latest Version docs Chat on Miaou

Definition of ANSI, RGB and HSL color types and all the conversions between them.

There are many other color conversion crates. This one is no-std and may be useful when you're interested into

  • variations of an ANSI color for your TUI application, for example fading, lightening, darkening, with compatibility with terminals that don't support RGB.
  • translations of color schemes
  • automatic downgrading of RGB color schemes for non RGB terminals
  • automated building of harmonious color schemes with guarantees of contrast
  • etc.

Coolor is used in SafeCloset to dynamically fade the background behind a dialog:


Be warned that the ANSI range is intrinsically limited to 240 colors and that not all intuitive operations will give good results.

Coolor doesn't contain functions to print on the terminal, but the colors can be used in other crates. There's an optional feature for conversion from and into Crossterm colors. You'll see it used in the included examples.

Note: the RGB to ANSI conversion is performed using the ansi_colours crate. Condider using it directly if you don't need the other features of coolor.

Included Examples


Luminosity and saturation variations of all 240 ANSI colors, with all variants still ANSI colors.



Several ways to mix colors



Finding the nearest ANSI color from a RGB one