Guide

How to Convert Kelvin to RGB and Hex Color Values

The formula behind the swatches, with worked examples

Designers, game developers, 3D artists and smart-lighting hobbyists often need a screen color that represents a light source: "what RGB value is 2700K?" There is no single official answer, because a kelvin value describes a spectrum of light while an RGB value describes how a display mixes red, green and blue. But there are well-established approximations, and Color Temp uses one of them to draw every swatch on the scale and to show the hex and RGB values in the Lookup tab. This guide explains how it works and how far to trust the result.

Short answer

Color Temp converts kelvin to RGB with a widely used curve-fit approximation of black-body color, published by developer Tanner Helland in 2012. It produces, for example, #ffa757 for 2700K, #ffcea6 for 4000K and #fffefa for 6500K. The output is good for visualising relative warmth and for design work, but it is not a colorimetric conversion and will not match a physical bulb exactly.

What the conversion is trying to do

A black body is an idealised object that glows when heated, with a color determined only by its temperature. Physicists can compute the exact spectrum it emits at any temperature using Planck's law, and from that spectrum compute a precise color in the CIE color spaces used in color science. Turning that into an sRGB value for a screen requires choosing a white point, normalising brightness, and deciding what to do with colors outside the screen's gamut.

A full colorimetric pipeline is overkill for a web page that needs a pleasing swatch. So many tools, including Color Temp, use a simpler approach: a set of curves fitted to precomputed black-body RGB data, which take a temperature and return red, green and blue values directly. The Kelvin chart covers the physics in plain language.

The formula Color Temp uses

The algorithm first clamps the input to 1000–40000K and divides by 100. Call the result T. Then each channel is computed separately and clamped to 0–255:

Red

Green

Blue

Each channel is rounded to a whole number and written as two hex digits to form the hex code. In JavaScript the whole thing is about ten lines, which is why the Color Temp page can compute every swatch in your browser without contacting a server.

Worked example: 2700K

  1. 2700 is within 1000–40000, so T = 2700 ÷ 100 = 27.
  2. Red: T ≤ 66, so red = 255.
  3. Green: ln(27) ≈ 3.2958. 99.4708 × 3.2958 ≈ 327.84. 327.84 − 161.12 ≈ 166.72, which rounds to 167.
  4. Blue: T is between 19 and 66, so use ln(27 − 10) = ln(17) ≈ 2.8332. 138.5177 × 2.8332 ≈ 392.46. 392.46 − 305.04 ≈ 87.41, which rounds to 87.
  5. Result: rgb(255, 167, 87). In hex: ff, a7, 57, so #ffa757.

Worked example: 7500K, above the white point

Values above 6600K take the other branch of each formula, which is where the result turns blue.

  1. T = 7500 ÷ 100 = 75. Because T is above 66, red and green use the power curves, and blue is fixed.
  2. Red: T − 60 = 15. 15−0.1332 ≈ 0.6972. 329.6987 × 0.6972 ≈ 229.86, which rounds to 230.
  3. Green: 15−0.0755 ≈ 0.8151. 288.1222 × 0.8151 ≈ 234.84, which rounds to 235.
  4. Blue: T ≥ 66, so blue = 255.
  5. Result: rgb(230, 235, 255), or #e6ebff, a pale sky blue.

Compare the two examples. Below the white point, red is pinned at 255 and the other channels climb as the temperature rises. Above it, blue is pinned at 255 and red and green slowly fall. That asymmetry is why the scale looks orange over a wide span of low values and only gently blue at the top: the curve changes quickly at the warm end and slowly at the cool end, matching the way the eye perceives kelvin steps.

Reference table

These values are the output of the same function the tool uses:

KelvinRGBHex
1500K255, 108, 0#ff6c00
1900K255, 132, 0#ff8400
2200K255, 146, 39#ff9227
2700K255, 167, 87#ffa757
3000K255, 177, 110#ffb16e
3500K255, 193, 141#ffc18d
4000K255, 206, 166#ffcea6
5000K255, 228, 206#ffe4ce
5500K255, 237, 222#ffedde
6500K255, 254, 250#fffefa
6600K255, 255, 255#ffffff
7500K230, 235, 255#e6ebff
10000K202, 218, 255#cadaff

For any other value, type it into the Color Temp Lookup tab, which shows the hex and RGB alongside the zone it belongs to.

Why the white point sits near 6600K

Notice that the formula reaches pure white, #ffffff, at about 6600K. That is because sRGB, the standard color space for most screens and the web, defines its white as CIE standard illuminant D65, which corresponds to a correlated color temperature of roughly 6500K. Anything warmer than the display's white shows up as orange-tinted; anything cooler shows up as blue-tinted. The curve fit lands its neutral point close to, but not exactly on, 6500K. D65 is also based on a daylight spectrum rather than a pure black body, so the two are not identical anyway. For more on display white, see screen white point and night mode.

Limitations to keep in mind

Practical uses

Keep reading

Open the Color Temp reference