---
slug: hex-color-mixer-calculator
title: "Hex Color Mixer Calculator"
category: developer
updated: 2026-11-17
canonical: https://calcseed.com/c/developer/hex-color-mixer-calculator/
html: /c/developer/hex-color-mixer-calculator/
---

# Hex Color Mixer Calculator

Mix two hex colors by a percentage and get the resulting hex and RGB values. Free, instant and runs in your browser.

## Formula

```text
result = color1 + (color2 − color1) × (mix ÷ 100)
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| Color 1 | text |  | #ff0000 |
| Color 2 | text |  | #0000ff |
| Mix | number | % | 50 |

## Outputs

| Result | Format |
| --- | --- |
| Mixed color | primary |
| Mixed color | text |
| RGB | text |

## How it works

### How the mixer blends two colors

Each hex color is unpacked into its red, green and blue channels, each an integer from 0 to 255. The mixer then interpolates every channel separately between color 1 and color 2 by your mix percentage, rounds each result to the nearest integer, and packs the three values back into a hex string and an rgb() triple. Two channels never influence each other, so what changes between 40% and 60% mix is exactly the same shift applied independently to red, green and blue.

The interpolation factor t is your mix percentage divided by 100, clamped to the range 0 to 1. At t = 0 the result is exactly color 1, at t = 1 exactly color 2, and at t = 0.5 the midpoint of every channel. This is plain linear interpolation, the same arithmetic behind CSS color transitions and canvas gradient stops.

### Worked example at the default colors

The defaults mix **#ff0000** (red, rgb(255, 0, 0)) with **#0000ff** (blue, rgb(0, 0, 255)) at 50%. The red channel moves 255 + (0 − 255) × 0.5 = 127.5, which rounds to 128, or 0x80 in hex. The green channel stays at 0. The blue channel performs the same 127.5 &rarr; 128 move as red. The result is **#808080**, or rgb(128, 0, 128) — a dark purple on the way to gray.

#### Rounding at the midpoint

The two rounded halves are worth noticing: 127.5 is not representable in an 8-bit channel, so the tool must round, and .5 always rounds up here. That is why a true 50/50 mix of two complementary colors lands on 128 rather than the 127.5 a spreadsheet would show you.

### Every mix step between the defaults

| Mix | Hex result | RGB | Channel math (red) |
| --- | --- | --- | --- |
| 0% | #ff0000 | rgb(255, 0, 0) | 255 + (0 − 255) × 0 = 255 |
| 25% | #bf00bf | rgb(191, 0, 191) | 255 × 0.75 = 191.25 &rarr; 191 (bf) |
| 50% | #808080 | rgb(128, 0, 128) | 255 × 0.5 = 127.5 &rarr; 128 (80) |
| 75% | #400040 | rgb(64, 0, 64) | 255 × 0.25 = 63.75 &rarr; 64 (40) |
| 100% | #0000ff | rgb(0, 0, 255) | 255 + (0 − 255) × 1 = 0 |

Reading the red column shows why the sequence looks slightly lopsided: the 25% step covers 64 units of change while the 50% point sits only 1 unit past the exact midpoint, purely because of rounding. Percentages map to channel values linearly; the display names just snap to whole numbers.

### Hex and RGB are the same numbers

A hex pair like 80 is simply 128 written in base 16, so #808080 and rgb(128, 128, 128) describe one identical color. The mixer reports both formats because CSS accepts either, and design tools differ in preference. A three-digit shorthand such as #f00 is expanded to #ff0000 before mixing, doubling each digit, so #abc becomes #aabbcc first.

#### Why some mixes look muddy

sRGB channels are gamma-encoded, so averaging them is not the same as averaging light. Mixing complementary hues, as the red-plus-blue default does, drains saturation on the way and produces the muted purple and eventual gray visible in the table. This is expected behavior for channel-wise interpolation — designers who need perceptually even steps mix in OKLCH or LAB space instead, where 50% really looks like the halfway color to the eye.

### Practical uses and inputs

#### Building tint and shade ramps

- Deriving hover states: mix your button color 15–20% toward white or black instead of hand-picking a shade
- Building tint ramps: mix a brand color 0%, 25%, 50%, 75% and 100% toward white for a five-step scale
- Checking contrast candidates: blend a text color toward the background to see where it stops separating
- Sampling between two brand colors for gradient midpoints before writing the CSS stops

For ramps toward white, set color 2 to #ffffff and read the 25% and 50% rows; toward black, use #000000. Mixing #ff0000 toward white at 50% gives rgb(255, 128, 128), the familiar pastel pink, because only red stays saturated.

### Edge cases to know

Invalid input returns an error rather than a guess: anything that is not a valid 3- or 6-digit hex value after stripping the # sign stops the calculation, so a stray letter in the hex string cannot silently produce a wrong color. Mix values outside 0–100 are clamped to the nearer bound, so 150% behaves exactly like 100%. The result always rounds to whole channels, because both hex and rgb() notations only express integers from 0 to 255 — there is no such thing as a fractional channel in CSS.

When you need the mixed color converted the other direction — into HSL for hue tweaks, or into a full palette — the Color Converter and Color Hex Calculator handle the formats this mixer deliberately keeps simple.

## FAQ

### What does 50% mixing mean exactly?

Every channel is moved halfway from color 1 to color 2. Mixing #ff0000 with #0000ff at 50% gives rgb(128, 0, 128) / #808080, because each of the 255-unit channels moves 127.5 units and rounds to 128.

### Can I use three-digit hex like #f00?

Yes. Shorthand colors are expanded by doubling each digit, so #f00 becomes #ff0000 and #abc becomes #aabbcc before the mix runs. The output is always the full 6-digit form.

### Why does mixing red and blue give purple and not violet?

Channel-wise interpolation in sRGB passes through desaturated territory between complementary hues. The default mix yields #808080 at 50%, a gray-leaning purple. Perceptual color spaces such as OKLCH produce more vivid midpoints, but sRGB mixing is what CSS itself does.

### What is the result at 25% and 75%?

At 25% toward the second color the red channel is 255 × 0.75 = 191.25, which rounds to 191, giving #bf00bf. At 75% the channel is 63.75, rounding to 64, giving #400040.

### Why is the 50% value 128 and not 127.5?

Channels only store whole numbers from 0 to 255, so the midpoint must round. This tool rounds halves up, so 127.5 becomes 128 (hex 80). Some libraries round down and produce #7f007f instead — a one-unit difference that is visually indistinguishable.

### Does the order of the two colors matter?

Mathematically no — the interpolation formula is symmetric, so mixing A into B at 50% equals mixing B into A at 50%. It only matters at unequal percentages, where the mix value is always measured from color 1 toward color 2.

### How do I make a lighter version of my color?

Mix it toward #ffffff. At 50%, #ff0000 becomes rgb(255, 128, 128); at 25% it becomes rgb(255, 191, 191). Use 15–20% for hover states and 10–25% steps for tint ramps.

### What happens with an invalid hex input?

The tool reports an error instead of computing, so a typo like #ff00zz never silently returns a wrong color. Only 3-digit and 6-digit hex values are accepted, with or without the leading #.

### Is the output safe to paste into CSS?

Yes. Both the hex form #808080 and the rgb(128, 0, 128) form are valid CSS Color 4 values, and they describe exactly the same color, so use whichever your stylesheet prefers.

## Method and sources

Methodology: Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: 2026-11-17.
- Linear interpolation of sRGB color channels.
