Xerobit

Color Mixer: Blend Two Hex Colors

Enter two hex color codes and a blend ratio to mix them instantly. This color mixer runs entirely in your browser so nothing is uploaded. Choose between standard sRGB interpolation for quick CSS work or linear light blending for physically accurate results when you mix colors for design projects.

Result

  • Mixed hex
    #800080
  • RGB
    rgb(128, 0, 128)
  • HSL
    hsl(300, 100%, 25%)
StepHex
1#FF0000
2#BF0040
3#800080
4#4000BF
5#0000FF

How to use the color mixer

  1. Enter the first hex color code in Color A. You can use 3-digit shorthand like F00 or full 6-digit codes like #FF0000.
  2. Enter the second hex color in Color B.
  3. Set the Ratio slider or number field. This controls how much of Color B appears in the final blend (0 means pure A, 100 means pure B).
  4. Choose a Blend space: sRGB for standard CSS mixing, or Linear light to mix as physical light intensity (midpoints come out brighter).
  5. Read the mixed hex, rgb() and hsl() values below, along with a five-step gradient table.

How sRGB blending works

In sRGB mode the color mixer interpolates each channel independently using the formula C = round(A + (B - A) * t), where t is the ratio divided by 100. For example, mixing #FF0000 (red) and #0000FF (blue) at 50 percent gives red = round(255 + (0 - 255) * 0.5) = 128, green = 0, blue = 128, which is #800080. Rounding uses half-up so 127.5 becomes 128.

This approach matches how most CSS tools and image editors blend colors by default. It is fast, but sRGB values are gamma-encoded rather than proportional to actual light intensity, so the result is not a physical light mix. Neither mode is perceptually uniform; for that you would need a space such as OKLab or OKLCH.

Why linear light blending matters

sRGB stores colors with a gamma curve that compresses dark tones. Blending the encoded values directly is not what happens when two lights of different colors actually add together. Linear light blending converts each channel to linear intensity before mixing, which models physical light mixing and is the correct basis for things like resizing images or simulating overlapping light sources. It does not make the result perceptually even: the midpoints it produces usually look brighter than the plain sRGB average.

The conversion from an sRGB channel value c (scaled 0 to 1) to linear follows the sRGB transfer function: if c is 0.04045 or less, linear = c / 12.92; otherwise linear = ((c + 0.055) / 1.055)2.4. After interpolation the result is converted back using the inverse function. Mixing black (#000000) and white (#FFFFFF) at 50 percent in linear light yields approximately #BCBCBC instead of the sRGB midpoint #808080, because a linear value of 0.5 maps back to an sRGB value near 0.735, which rounds to 188 (hex BC).

Common blend reference table

Use this table as a quick reference when you mix colors in sRGB mode at a 50 percent ratio.

Color AColor BMixed (sRGB 50%)
#FF0000#0000FF#800080
#FF0000#00FF00#808000
#000000#FFFFFF#808080
#0000FF#FFFF00#808080
#FF8800#0088FF#808880

Practical uses for a color mixer

Designers use a color mixer online to generate palette variations, create smooth gradients and check contrast between blended shades. Developers building themes often need to derive hover states or disabled colors by blending a base color toward white or black at a fixed ratio.

When you mix hex colors for gradients, compare both modes. Linear light blending keeps the physical intensity consistent and avoids the dark, muddy band that sRGB can show between saturated colors, but it brightens midpoints, and its steps are not perceptually even. For UI components like progress bars or overlays, sRGB blending is usually preferred because it matches how browsers render CSS gradients and transitions natively.

Handling hex formats and edge cases

This tool accepts 3-digit and 6-digit hex codes with or without the leading hash symbol. Hex codes with an alpha channel (4 or 8 digits) are not supported and are rejected. A 3-digit code like #F00 is expanded to #FF0000 by doubling each character. Invalid characters or wrong-length strings produce a clear error message.

A ratio of exactly 0 always returns Color A unchanged, and 100 returns Color B. Values outside the 0 to 100 range are rejected. The output includes the mixed hex code alongside rgb() and hsl() representations so you can paste the result directly into CSS. If you also need to pick a starting color visually, try the color picker to grab a hex code first.

Worked examples

ExampleInputResult
Red and Blue at 50%Color A (hex): #FF0000; Color B (hex): #0000FF; Ratio (% of Color B): 50; Blend space: srgbMixed hex: #800080; RGB: rgb(128, 0, 128); HSL: hsl(300, 100%, 25%)
Black and White linearColor A (hex): #000000; Color B (hex): #FFFFFF; Ratio (% of Color B): 50; Blend space: linearMixed hex: #BCBCBC; RGB: rgb(188, 188, 188); HSL: hsl(0, 0%, 74%)
Short hex codesColor A (hex): F00; Color B (hex): 00F; Ratio (% of Color B): 25; Blend space: srgbMixed hex: #BF0040; RGB: rgb(191, 0, 64); HSL: hsl(340, 100%, 37%)
Pure Color AColor A (hex): #112233; Color B (hex): #FFEEDD; Ratio (% of Color B): 0; Blend space: srgbMixed hex: #112233; RGB: rgb(17, 34, 51); HSL: hsl(210, 50%, 13%)

FAQ

What does the ratio control?

The ratio sets how much of Color B is present in the blend. A ratio of 0 gives pure Color A, 100 gives pure Color B, and 50 is an equal mix of both.

What is the difference between sRGB and linear light blending?

sRGB blending mixes the encoded channel values directly, which is fast but can make midpoints look too dark. Linear light blending converts channels to physical light intensity first, which models real light mixing but makes midpoints look brighter, not more perceptually even.

Can I enter short hex codes like #F00?

Yes. Three-digit hex codes are automatically expanded by doubling each character, so #F00 becomes #FF0000 before mixing.

Is my color data sent to a server?

No. This color mixer runs entirely in your browser. Nothing is uploaded or stored.

Why does black and white at 50% give #BCBCBC in linear mode?

In linear light, a 50% mix corresponds to half the physical light intensity. Converting that back through the sRGB gamma curve yields approximately 0.735 per channel, which rounds to 188 (hex BC).

Can I use the output directly in CSS?

Yes. The tool provides the mixed color as a hex code, an rgb() function and an hsl() function, all of which are valid CSS color values.