How to use
- Enter a HEX, RGB or HSL value for Color A and Color B, or pick them with the color pickers.
- Set the ratio with the Share of B slider. 0 is pure A, 100 is pure B and 50 is an even mix. Swapping A and B flips the share as well.
- Choose a blend method. The same two colors give different midpoints depending on the method.
- The preview on top is the mixed color. Set the number of steps (3 to 11) to list evenly spaced in-between colors from A to B as HEX.
- Copy the
color-mix()and gradient code below straight into your CSS.
Methods compared
| Method | Calculation | Character |
|---|---|---|
| sRGB | Averages screen values (0 to 255) directly | The simplest and most common |
| Linear RGB | Removes gamma, mixes light intensity, then converts back | Closer to mixing real light, so midpoints are brighter |
| OKLab | Averages in OKLab coordinates that feel even to the eye | Natural midpoints with even lightness |
An even 50:50 mix in the three methods:
| Color A | Color B | sRGB | Linear RGB | OKLab |
|---|---|---|---|---|
#ff0000 |
#0000ff |
#800080 |
#bc00bc |
#8c53a2 |
#ffffff |
#000000 |
#808080 |
#bcbcbc |
#636363 |
#ff0000 |
#00ff00 |
#808000 |
#bcbc00 |
#d0a800 |
#3366cc |
#ff5b1f |
#996176 |
#be6197 |
#a3718c |
An even mix of white and black is #808080 in sRGB, a much brighter #bcbcbc in linear RGB and a darker #636363 in OKLab. None is wrong. They differ in what is being averaged.
Steps and CSS code
Splitting #3366cc to #ff5b1f into 5 steps in sRGB gives #3366cc, #6663a1, #996176, #cc5e4a and #ff5b1f. In OKLab it is #3366cc, #726fae, #a3718c, #d26b65 and #ff5b1f, with brighter, more even midpoints.
color-mix() is a CSS color function, and its percentage is the share of the first color (A). With 30% of B you get color-mix(in oklab, #3366cc 70%, #ff5b1f). The gradient output uses the same idea as linear-gradient(in oklab to right, ...). This syntax needs a reasonably recent browser, so use the step HEX values if you must support older ones.
Things to keep in mind
- This calculates mixing of screen light. Red and green light make yellow, but pigments mix differently: yellow and blue paint make green. On screen, mixing
#ffff00and#0000ffevenly gives gray (#808080), not green. For matching a paint color, see HEX to Paint Color Guide. - If a result falls outside the sRGB range, it is fitted to the nearest displayable color.
- For lighter and darker versions of one color, use Color Shades Generator. For matching color schemes, use Color Palette Generator. For gradients across several stops, use CSS Gradient Generator.
Frequently asked questions
How do I find the midpoint of two colors?
Set the share to 50. Different methods give slightly different midpoints, so choose OKLab if you want the one that looks most natural.
What do red and blue make when mixed?
On screen values, an even sRGB mix is #800080, a purple. Depending on the method you can also get #bc00bc or #8c53a2.
Can it mix like paint?
No. This is additive mixing of light. Paint mixes subtractively and gives different results.
Is my color sent to a server?
No. All calculations run in your browser and nothing is sent to a server.