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.
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
- If T ≤ 66: red = 255.
- Otherwise: red = 329.698727446 × (T − 60)−0.1332047592.
Green
- If T ≤ 66: green = 99.4708025861 × ln(T) − 161.1195681661.
- Otherwise: green = 288.1221695283 × (T − 60)−0.0755148492.
Blue
- If T ≥ 66: blue = 255.
- If T ≤ 19: blue = 0.
- Otherwise: blue = 138.5177312231 × ln(T − 10) − 305.0447927307.
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
- 2700 is within 1000–40000, so T = 2700 ÷ 100 = 27.
- Red: T ≤ 66, so red = 255.
- Green: ln(27) ≈ 3.2958. 99.4708 × 3.2958 ≈ 327.84. 327.84 − 161.12 ≈ 166.72, which rounds to 167.
- 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.
- 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.
- T = 7500 ÷ 100 = 75. Because T is above 66, red and green use the power curves, and blue is fixed.
- Red: T − 60 = 15. 15−0.1332 ≈ 0.6972. 329.6987 × 0.6972 ≈ 229.86, which rounds to 230.
- Green: 15−0.0755 ≈ 0.8151. 288.1222 × 0.8151 ≈ 234.84, which rounds to 235.
- Blue: T ≥ 66, so blue = 255.
- 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:
| Kelvin | RGB | Hex |
|---|---|---|
| 1500K | 255, 108, 0 | #ff6c00 |
| 1900K | 255, 132, 0 | #ff8400 |
| 2200K | 255, 146, 39 | #ff9227 |
| 2700K | 255, 167, 87 | #ffa757 |
| 3000K | 255, 177, 110 | #ffb16e |
| 3500K | 255, 193, 141 | #ffc18d |
| 4000K | 255, 206, 166 | #ffcea6 |
| 5000K | 255, 228, 206 | #ffe4ce |
| 5500K | 255, 237, 222 | #ffedde |
| 6500K | 255, 254, 250 | #fffefa |
| 6600K | 255, 255, 255 | #ffffff |
| 7500K | 230, 235, 255 | #e6ebff |
| 10000K | 202, 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
- It is a fit, not a derivation. The curves approximate black-body data closely enough for visual use, but they are not exact colorimetry.
- Brightness is normalised. At least one channel is always at or near 255, so every swatch is as bright as possible. Real light sources at different temperatures are not.
- Real lamps are not black bodies. An LED rated 2700K is a correlated color temperature and may sit slightly green or pink of the black-body color. The swatch cannot show that.
- Your display changes the result. Calibration, brightness, a night mode or a wide-gamut screen all alter what
#ffa757looks like.
Practical uses
- UI and illustration: picking a "warm lamp" or "daylight" tint for a scene, then using it at low opacity as an overlay.
- 3D and game engines: many renderers accept kelvin directly; where they do not, an RGB light color from this table is a reasonable start.
- Smart lighting: some RGB bulbs accept only RGB values. The table gives a rough target, though dedicated white LEDs in tunable bulbs usually render whites better than RGB mixing.