Skip to main content
CalcChef

Color Mixer

Mix two to four hex colors by weight in OKLab, sRGB or linear light: red and blue at 50% give #8c53a2 in OKLab. Copy HEX, RGB, HSL, OKLCH or CSS color-mix(). How it works

Use the Color Mixer

Left: 100% Color 1Right: 100% Color 2
Blend in

OKLab (perceptual) mixes in the OKLab colour space, which keeps lightness and saturation closer to what the eye sees.

Presets
Mixed color
#8c53a2
vs White
5.42:1
AA: passAAA: failAA Large: pass
vs Black
3.87:1
AA: failAAA: failAA Large: pass
:root {
  --color-1: #ff0000;
  --color-2: #c6496d;
  --color-3: #8c53a2;
  --color-4: #5147d2;
  --color-5: #0000ff;
}

About the Color Mixer

Red #ff0000 and blue #0000ff mixed 50/50 give #8c53a2 in OKLab, #800080 in sRGB and #bc00bc in linear light. The color mixer blends two hex colors at any ratio from 0 to 100%, or up to four colors by relative weight, in the space you pick and gives the result as HEX, RGB, HSL, OKLCH and a CSS color-mix() line, with its contrast against white and black. The gradient between colors 1 and 2 copies as CSS variables, an SCSS map, Tailwind colors, JSON or a hex list.

50/50 mixes in the three spaces

Color 1Color 2OKLabsRGBLinear light
#ff0000#0000ff#8c53a2#800080#bc00bc
#ffffff#000000#636363#808080#bcbcbc
#ff0000#00ff00#d0a800#808000#bcbc00
#ffff00#0000ff#6cabc7#808080#bcbcbc
#ffcc00#0066ff#8ea7b7#809980#bca3bc
#ff7e5f#feb47b#ff9a6d#ff996d#ff9c6e
#2193b0#6dd5ed#4ab4ce#47b4cf#52b8d1
#134e5e#71b280#427f71#42806f#538c71

The last three pairs are the Sunset, Ocean and Forest presets. Close colors give close results in every space; the spaces differ most for colors far apart.

Red to blue in 5 steps (OKLab)

Share of Color 2Hex
0%#ff0000
25%#c6496d
50%#8c53a2
75%#5147d2
100%#0000ff

White and black at 50%: contrast of the mix

SpaceMixOn whiteOn black
OKLab#6363636.00:13.49:1
sRGB#8080803.94:15.31:1
Linear light#bcbcbc1.89:111.05:1

Ratios are truncated to two decimals, not rounded, so a pair never shows a pass it does not have.

Frequently asked questions

What color do red and blue make?
Mixed 50/50 as screen colors: #8c53a2 in OKLab, which is rgb(140, 83, 162) and hsl(283, 32%, 48%); #800080 in sRGB; and #bc00bc in linear light.
Why does each mode give a different color?
Each averages different numbers. sRGB averages the stored 0 to 255 values, so midpoints are darker and duller than the light they stand for; linear light averages the light itself and comes out brighter; OKLab keeps lightness and saturation closer to what the eye sees. White and black at 50% give #808080, #bcbcbc and #636363.
How do I write the mix in CSS?
Copy the CSS color-mix() line: red and blue at 50% in OKLab is color-mix(in oklab, #ff0000 50%, #0000ff). CSS gives the share of the first color, so with the slider at 25% (25% Color 2) in linear light the line is color-mix(in srgb-linear, #ff0000 75%, #0000ff).
How do I make a darker or lighter shade of a color?
Set Color 2 to black or white and move the slider to the share you want. #2193b0 with 20% black in OKLab gives #166c82, and with 20% white gives #5ca8c0. The darker shade also fixes contrast: #2193b0 is 3.58:1 on white and fails AA for normal text, while #166c82 is 5.99:1 and passes.
Can I mix three or four colors?
Yes. Add color brings in a third and a fourth color, and each color gets a weight slider from 0 to 100. Weights are relative, so 1:1:2 and 25:25:50 give the same mix. Red, blue and green at 1:1:2 in OKLab give #7dae83, and the CSS line nests two-color mixes: color-mix(in oklab, color-mix(in oklab, #ff0000 50%, #0000ff) 50%, #00ff00). At equal weights the three give #869290. A color at weight 0 is left out.
Can I share a mix?
Copy shareable URL puts color1, color2, ratio, blendMode (perceptual, srgb or linear-light) and s (steps, 2 to 20) in the link, plus color3, color4 and the weights w1 to w4 when you mix more than two. An older link with blendMode=linear opens in sRGB, the gamma-encoded mixing it used to mean.

Related Tools

View all tools