Every dayText & Encoding

Color Harmony
calculator.

Build a matching palette from any hex, RGB or HSL color, with text contrast.

How it's worked out

The tool turns your color into HSL: hue, saturation and lightness. Hue is an angle round the color wheel, where 0° is red, 120° is green and 240° is blue. Saturation runs from gray at 0% to full color at 100%. Lightness runs from black at 0% to white at 100%, with the pure color at 50%.

Each harmony adds fixed angles to the hue, then turns the result back into a color. Saturation and lightness stay the same, so the colors feel like one family.

new hue\displaystyle \text{new hue}=(base hue+offset)mod360\displaystyle {}= (\text{base hue} + \text{offset}) \bmod 360
The angle each harmony adds to the base hue
HarmonyOffsets
Complementary180°
Split complementary150°, 210°
Analogous-30°, 30°
Triadic120°, 240°
Square (tetradic)90°, 180°, 270°
Rectangle (tetradic)60°, 180°, 240°

Pure red shows the idea: its triadic partners are #00FF00 and #0000FF, the pure green and blue of a screen. The monochromatic scheme keeps the hue and steps the lightness instead.

For text, the tool uses the WCAG 2.2 contrast ratio. It compares how light two colors look on a screen and gives a figure from 1:1, the same color, up to 21:1 for black on white.

Worked examples

Nadia picks a second color for her bakery

Nadia's logo is the gold #E0A800, a hue of 45°. Its complement sits opposite, at 225°: #0038E0, a blue. Black text on the gold scores 9.77:1, so her menu can use it freely.

The two colors together reach 3.70:1, which WCAG rates "AA large". That is fine for a big heading in blue on gold, but under 4.5:1, so it is not enough for the small print on her price list.

Open this example in the tool

Leo chooses series colors for a dashboard

Leo's product blue is #2F6FDB. The split complementary scheme adds #DB452F (red, 8°) and #C5DB2F (yellow, 68°). The three hues are far apart, so chart lines in these colors are easy to tell apart.

None of the pairs is good for text: the best is 3.07:1. So Leo puts labels in white or black on each color, keeps the palette for lines and bars, and uses a tint such as #97B7ED for a light panel.

Open this example in the tool

Sam finds that gray does not turn

Sam's brand gray is #6B7280, at only 9% saturation. Its complement is #80796B, and the two score 1.12:1, close to identical. With so little color, turning the hue has almost nothing to turn.

The monochromatic scheme works better for Sam. It keeps the hue and gives six lightness steps from #23252A to #E3E5E8. Of the 15 pairs, 5 reach 4.5:1, so there are several safe choices for text on a background.

Open this example in the tool

Reading your result

The swatches are a starting point. Harmony rules give hues that sit well together. Most real designs use one color for most of the space, a second for support and a third, sparingly, for buttons and links, with neutral grays around them.

Text needs contrast, not harmony. WCAG 2.2 asks for 4.5:1 for body text and 3:1 for large text, which it defines as 18 point, or 14 point bold. The enhanced level asks for 7:1. Buttons, form borders and chart parts also need 3:1 against what sits next to them.

Equal lightness does not look equal. HSL lightness is a simple average of the red, green and blue channels. CSS Color 4 warns that it does not match what the eye sees: yellow and blue at 50% look very different. Against black, #FFFF00 scores 19.56:1, while #0000FF needs white text, at 8.59:1.

Tints, shades and tones are lighter, darker and softer versions of the base. A tint mixes in white, which suits backgrounds. A shade mixes in black, which suits text and borders. A tone mixes in gray and calms a color that feels too strong.

Common mistakes

  • Setting text in one palette color on another. Colors that look good side by side often fail as text and background. Check the pair table before you set a paragraph in them.
  • Starting from a gray. A base under about 8% saturation barely changes when its hue turns. Pick the brand's strongest color as the base, or use the monochromatic scheme.
  • Using color as the only signal. WCAG asks that color is not the only way to show meaning. Add a label, an icon or a pattern to chart series and to error states.
  • Mixing up the two wheels. Screens mix red, green and blue light, and this tool uses that wheel. Paint wheels are built on red, yellow and blue, so a painter's complement can differ. Pure blue's complement here is #FFFF00.

Questions people ask

On the screen wheel this tool uses, pure blue at 240° pairs with #FFFF00, a yellow, at 60°. The pair scores 8.00:1, so blue text on that yellow is readable. Painters, who mix red, yellow and blue pigments, usually pair blue with orange instead.

Sources